Merge "Remove "only newlines in trailer" special case for category/language links"
[lhc/web/wiklou.git] / includes / htmlform / OOUIHTMLForm.php
index 9dd37b3..1755e98 100644 (file)
@@ -176,11 +176,17 @@ class OOUIHTMLForm extends HTMLForm {
         * @return string HTML
         */
        protected function formatSection( array $fieldsHtml, $sectionName, $anyFieldHasLabel ) {
+               if ( !$fieldsHtml ) {
+                       // Do not generate any wrappers for empty sections. Sections may be empty if they only have
+                       // subsections, but no fields. A legend will still be added in wrapFieldSetSection().
+                       return '';
+               }
+
                $config = [
                        'items' => $fieldsHtml,
                ];
                if ( $sectionName ) {
-                       $config['id'] = Sanitizer::escapeId( $sectionName );
+                       $config['id'] = Sanitizer::escapeIdForAttribute( $sectionName );
                }
                if ( is_string( $this->mWrapperLegend ) ) {
                        $config['label'] = $this->mWrapperLegend;