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.
Have a look at print_collapsible_region. Quite old code, but it still works I think.
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?
An alternative is to use tabs
You can see an example of it being used on a course Grader report page (/grade/report/grader/index.php)
$rows = array(
echo $OUTPUT->tabtree($rows, $selectedid);