Merge "HTMLForm: Do not generate wrappers for empty sections"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Sat, 23 Sep 2017 12:13:36 +0000 (12:13 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sat, 23 Sep 2017 12:13:36 +0000 (12:13 +0000)
includes/htmlform/HTMLForm.php
includes/htmlform/OOUIHTMLForm.php

index 465736b..d959dd2 100644 (file)
@@ -1723,6 +1723,12 @@ class HTMLForm extends ContextSource {
         * @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 '';
+               }
+
                $displayFormat = $this->getDisplayFormat();
                $html = implode( '', $fieldsHtml );
 
index e47de61..1755e98 100644 (file)
@@ -176,6 +176,12 @@ 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,
                ];