From: Florian Date: Thu, 25 Jun 2015 12:56:05 +0000 (+0200) Subject: Fix Button label in OOUI HTML Form and enable flags X-Git-Tag: 1.31.0-rc.0~10949^2 X-Git-Url: http://git.cyclocoop.org/%7D%7Cconcat%7B?a=commitdiff_plain;h=1025f0a79c0ac5d02806ca24fc9c54513d63a7cf;p=lhc%2Fweb%2Fwiklou.git 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 --- 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' ); }