Fix Button label in OOUI HTML Form and enable flags
authorFlorian <florian.schmidt.welzow@t-online.de>
Thu, 25 Jun 2015 12:56:05 +0000 (14:56 +0200)
committerFlorian <florian.schmidt.welzow@t-online.de>
Thu, 25 Jun 2015 12:56:05 +0000 (14:56 +0200)
An OOUI Button now adds the value as a label of the button, too. Enable
the HTMLForm descriptor to pass flags to the OOUI Button widget, which
defaults to nothing in HTMLButtonField and to 'primary' and 'constructive'
in HTMLSubmitField.

Change-Id: Ibf561453604a830862d4f64819c8418a9458cb12

includes/htmlform/HTMLButtonField.php
includes/htmlform/HTMLSubmitField.php

index 9f30ee3..afd7cf6 100644 (file)
 class HTMLButtonField extends HTMLFormField {
        protected $buttonType = 'button';
 
+       /** @var array $mFlags Flags to add to OOUI Button widget */
+       protected $mFlags = array();
+
        public function __construct( $info ) {
                $info['nodata'] = true;
+               if ( isset( $info['flags'] ) )
+                       $this->mFlags = $info['flags'];
                parent::__construct( $info );
        }
 
@@ -33,9 +38,11 @@ class HTMLButtonField extends HTMLFormField {
                return new OOUI\ButtonInputWidget( array(
                        'name' => $this->mName,
                        'value' => $value,
+                       'label' => $value,
                        'type' => $this->buttonType,
                        'classes' => array( 'mw-htmlform-submit', $this->mClass ),
                        'id' => $this->mID,
+                       'flags' => $this->mFlags,
                ) + $this->getAttributes( array( 'disabled', 'tabindex' ), array( 'tabindex' => 'tabIndex' ) ) );
        }
 
index 653c08c..938e428 100644 (file)
@@ -6,4 +6,6 @@
  */
 class HTMLSubmitField extends HTMLButtonField {
        protected $buttonType = 'submit';
+
+       protected $mFlags = array( 'primary', 'constructive' );
 }