From 1025f0a79c0ac5d02806ca24fc9c54513d63a7cf Mon Sep 17 00:00:00 2001 From: Florian Date: Thu, 25 Jun 2015 14:56:05 +0200 Subject: [PATCH] Fix Button label in OOUI HTML Form and enable flags 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 | 7 +++++++ includes/htmlform/HTMLSubmitField.php | 2 ++ 2 files changed, 9 insertions(+) diff --git a/includes/htmlform/HTMLButtonField.php b/includes/htmlform/HTMLButtonField.php index 9f30ee3de1..afd7cf6d12 100644 --- a/includes/htmlform/HTMLButtonField.php +++ b/includes/htmlform/HTMLButtonField.php @@ -10,8 +10,13 @@ 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' ) ) ); } diff --git a/includes/htmlform/HTMLSubmitField.php b/includes/htmlform/HTMLSubmitField.php index 653c08c069..938e428a12 100644 --- a/includes/htmlform/HTMLSubmitField.php +++ b/includes/htmlform/HTMLSubmitField.php @@ -6,4 +6,6 @@ */ class HTMLSubmitField extends HTMLButtonField { protected $buttonType = 'submit'; + + protected $mFlags = array( 'primary', 'constructive' ); } -- 2.20.1