rahul
rahul

Reputation: 366

Moodle - Insert html in between form fields

Scenario:-

In Moodle I already have a form created which uses

$mform->addElement('hidden', 'category', $category->id);

to insert fields for the form.

I want to insert a table in middle of the form.

For Example. I have a form with fields user name, emp code and contact number. I want to insert a table between emp code and contact name. This table will have data which user has inputted.

I have a way to insert table at the end of the page using :-

echo $OUTPUT->header();
echo $OUTPUT->heading($pagedesc);
$table = new html_table();
$table->head = array('Name', 'Emp Code','Contact number');
echo html_writer::start_tag('div', array('class'=>'no-overflow'));
echo html_writer::table($table);
echo html_writer::end_tag('div');
echo $OUTPUT->footer();

Please suggest a way to insert table in middle of the form.

Upvotes: 0

Views: 2093

Answers (1)

Russell England
Russell England

Reputation: 10221

You can add html as a form element - https://docs.moodle.org/dev/lib/formslib.php_Form_Definition#html

$mform->addElement('html', $output);

Upvotes: 2

Related Questions