From: Bartosz DziewoƄski Date: Fri, 15 Sep 2017 20:26:11 +0000 (+0200) Subject: HTMLForm: Do not generate wrappers for empty sections X-Git-Tag: 1.31.0-rc.0~1982^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/journal.php?a=commitdiff_plain;h=7bee1a23046981c9bb34730f2af60364e5e268c9;p=lhc%2Fweb%2Fwiklou.git HTMLForm: Do not generate wrappers for empty sections This affects Special:Preferences, where there will no longer be an empty
after every toplevel section heading. Change-Id: Icb6fe957024843f2b08720715054b9afb657f395 --- diff --git a/includes/htmlform/HTMLForm.php b/includes/htmlform/HTMLForm.php index 465736bb06..d959dd2adc 100644 --- a/includes/htmlform/HTMLForm.php +++ b/includes/htmlform/HTMLForm.php @@ -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 ); diff --git a/includes/htmlform/OOUIHTMLForm.php b/includes/htmlform/OOUIHTMLForm.php index e47de61a4c..1755e98cfb 100644 --- a/includes/htmlform/OOUIHTMLForm.php +++ b/includes/htmlform/OOUIHTMLForm.php @@ -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, ];