- $attr = $this->getTooltipAndAccessKey();
- $attr['id'] = $this->mID;
- $attr['name'] = "{$this->mName}[]";
+ $optionsOouiSections = [];
+ $options = $this->getOptions();
+ // If the options are supposed to be split into sections, each section becomes a separate
+ // CheckboxMultiselectInputWidget.
+ foreach ( $options as $label => $section ) {
+ if ( is_array( $section ) ) {
+ $optionsOouiSections[ $label ] = Xml::listDropDownOptionsOoui( $section );
+ unset( $options[$label] );
+ }
+ }
+ // If anything remains in the array, they are sectionless options. Put them in a separate widget
+ // at the beginning.
+ if ( $options ) {
+ $optionsOouiSections = array_merge(
+ [ '' => Xml::listDropDownOptionsOoui( $options ) ],
+ $optionsOouiSections
+ );
+ }
+
+ $out = '';
+ foreach ( $optionsOouiSections as $sectionLabel => $optionsOoui ) {
+ $attr = [];
+ $attr['name'] = "{$this->mName}[]";