HTMLForm: Don't render 'mw-htmlform-submit-buttons' if there aren't any buttons
authorBartosz Dziewoński <matma.rex@gmail.com>
Fri, 22 Apr 2016 13:32:53 +0000 (15:32 +0200)
committerBartosz Dziewoński <matma.rex@gmail.com>
Fri, 22 Apr 2016 14:49:51 +0000 (14:49 +0000)
Visually, this only affects OOUIHTMLForm, in other kinds of forms
the element has no height anyway.

Change-Id: I90e73c49fbefec23532368848bb30b2e7b69075c

includes/htmlform/HTMLForm.php
includes/htmlform/OOUIHTMLForm.php
includes/htmlform/VFormHTMLForm.php

index 2b6a0aa..6f88975 100644 (file)
@@ -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";
        }
 
        /**
index 4f8365e..278d453 100644 (file)
@@ -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 ) {
index c446615..f3cba48 100644 (file)
@@ -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";
        }
 }