Can you use a .html file in $mform->addElement('html', ...)?

Can you use a .html file in $mform->addElement('html', ...)?

by Sean Thornber -
Number of replies: 1

Hi guys,

Firstly I'm super new to moodle development, so please go easy on me! 😊

I am wondering if in the second argument for adding an html element to a form you can use an actual html file rather than having to write out actual html in the second argument. Below is a test snippet to make what I'm talking about clearer:

$mform = $this->_form;
        $mform->addElement('header', 'config_header', 'test header');
        $mform->addElement('html', 
        '<style>
            #h1 {
                color: red;
            }
        </style>

        <div>
            <h1 id="h1">Hello world</h1>
        </div>'
        );

I ask because I want to use a .css style sheet as well as (not sure if this is actually possible in a moodle form) having php elements in the file.

Thanks !

Average of ratings: -
In reply to Sean Thornber

Re: Can you use a .html file in $mform->addElement('html', ...)?

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I don't see why not (if you must) but doesn't the html element type allow you to add a class name? I can't remember.