Form Header Without Form

Form Header Without Form

by Steven Norris -
Number of replies: 4

Is there a way to add a collapsible header like the moodleform uses without using a moodleform? I want to use that element to contain a table with inplace_editable elements in it, but would like not to have to create it from scratch if I can use the existing moodle element.

Average of ratings: -
In reply to Steven Norris

Re: Form Header Without Form

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Have a look at print_collapsible_region. Quite old code, but it still works I think.
In reply to Tim Hunt

Re: Form Header Without Form

by Steven Norris -
Is there any documentation or an example on how to use print_collapsible_region that you know of? I'm looking into it, but don't see anything outlined in the Moodle docs.
In reply to Tim Hunt

Re: Form Header Without Form

by Steven Norris -
Also, is there a way to expand/contract these regions afterward? Like on a form submit, can I snag the collapsible region by id and do a $region->expand(); or something?
In reply to Steven Norris

Re: Form Header Without Form

by Mark Sharp -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
An alternative is to use tabs


 $rows = array(
    new tabobject(...),
    new tabobject(...)
 );
 echo $OUTPUT->tabtree($rows, $selectedid);
You can see an example of it being used on a course Grader report page (/grade/report/grader/index.php)