Make the forms easier to use and navigate by adding functionality to
collapse and extend form sections (headers). The logic is as follows:
If form contains 2 and less sections (headers):
* Display the form as non-collapsible at all.
* The point above can be overridden if developer marks the section as expanded
in form definition (e.g. $mform->setExpanded('foo'));
If form contains 3 and more sections (headers):
* always expanding the first section and closing all others by default;
* always expanding a section containing at least one "required" element;
* expanding any section which contains validation errors after submission;
* expanding any section which was previously open on previous submit (e.g. when
adding new choices);
* expanding the section which is marked as expanded in form definition (e.g.
$mform->setExpanded('foo');