Merge "Don't add label-elements for elements that doesn't have one"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Mon, 14 Mar 2016 15:37:16 +0000 (15:37 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 14 Mar 2016 15:37:16 +0000 (15:37 +0000)
includes/htmlform/HTMLButtonField.php
includes/htmlform/HTMLFormField.php

index 0b07765..16417fc 100644 (file)
@@ -56,6 +56,8 @@ class HTMLButtonField extends HTMLFormField {
                        $this->buttonLabel = $info['buttonlabel-raw'];
                }
 
+               $this->setShowEmptyLabel( false );
+
                parent::__construct( $info );
        }
 
index 6e5d656..a9c7632 100644 (file)
@@ -610,12 +610,17 @@ abstract class HTMLFormField {
                $config = [
                        'classes' => [ "mw-htmlform-field-$fieldType", $this->mClass ],
                        'align' => $this->getLabelAlignOOUI(),
-                       'label' => new OOUI\HtmlSnippet( $this->getLabel() ),
                        'help' => $helpText !== null ? new OOUI\HtmlSnippet( $helpText ) : null,
                        'errors' => $errors,
                        'infusable' => $infusable,
                ];
 
+               // the element could specify, that the label doesn't need to be added
+               $label = $this->getLabel();
+               if ( $label ) {
+                       $config['label'] = new OOUI\HtmlSnippet( $label );
+               }
+
                return $this->getFieldLayoutOOUI( $inputField, $config );
        }