From: Bartosz DziewoƄski Date: Fri, 22 Apr 2016 13:32:53 +0000 (+0200) Subject: HTMLForm: Don't render 'mw-htmlform-submit-buttons' if there aren't any buttons X-Git-Tag: 1.31.0-rc.0~7207^2 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=cba7952e3185cc4a6c93617fd8e81be614272f89;p=lhc%2Fweb%2Fwiklou.git HTMLForm: Don't render 'mw-htmlform-submit-buttons' if there aren't any buttons Visually, this only affects OOUIHTMLForm, in other kinds of forms the element has no height anyway. Change-Id: I90e73c49fbefec23532368848bb30b2e7b69075c --- diff --git a/includes/htmlform/HTMLForm.php b/includes/htmlform/HTMLForm.php index 2b6a0aa4fb..6f88975912 100644 --- a/includes/htmlform/HTMLForm.php +++ b/includes/htmlform/HTMLForm.php @@ -1146,10 +1146,12 @@ class HTMLForm extends ContextSource { } } - $html = Html::rawElement( 'span', - [ 'class' => 'mw-htmlform-submit-buttons' ], "\n$buttons" ) . "\n"; + if ( !$buttons ) { + return ''; + } - return $html; + return Html::rawElement( 'span', + [ 'class' => 'mw-htmlform-submit-buttons' ], "\n$buttons" ) . "\n"; } /** diff --git a/includes/htmlform/OOUIHTMLForm.php b/includes/htmlform/OOUIHTMLForm.php index 4f8365e019..278d4532aa 100644 --- a/includes/htmlform/OOUIHTMLForm.php +++ b/includes/htmlform/OOUIHTMLForm.php @@ -121,10 +121,12 @@ class OOUIHTMLForm extends HTMLForm { ] + $attrs ); } - $html = Html::rawElement( 'div', - [ 'class' => 'mw-htmlform-submit-buttons' ], "\n$buttons" ) . "\n"; + if ( !$buttons ) { + return ''; + } - return $html; + return Html::rawElement( 'div', + [ 'class' => 'mw-htmlform-submit-buttons' ], "\n$buttons" ) . "\n"; } protected function wrapFieldSetSection( $legend, $section, $attributes ) { diff --git a/includes/htmlform/VFormHTMLForm.php b/includes/htmlform/VFormHTMLForm.php index c4466153a5..f3cba487a2 100644 --- a/includes/htmlform/VFormHTMLForm.php +++ b/includes/htmlform/VFormHTMLForm.php @@ -137,9 +137,11 @@ class VFormHTMLForm extends HTMLForm { $buttons .= Html::element( 'input', $attrs ) . "\n"; } - $html = Html::rawElement( 'div', - [ 'class' => 'mw-htmlform-submit-buttons' ], "\n$buttons" ) . "\n"; + if ( !$buttons ) { + return ''; + } - return $html; + return Html::rawElement( 'div', + [ 'class' => 'mw-htmlform-submit-buttons' ], "\n$buttons" ) . "\n"; } }