From: Florian Date: Thu, 23 Jul 2015 16:38:18 +0000 (+0200) Subject: HTMLForm: Allow to set the primary flag for submit buttons X-Git-Tag: 1.31.0-rc.0~10663^2 X-Git-Url: http://git.cyclocoop.org//%27%40script%40/%27?a=commitdiff_plain;h=3f7443df86832fec93303b12bf351e708841e460;p=lhc%2Fweb%2Fwiklou.git HTMLForm: Allow to set the primary flag for submit buttons Currently, every submit button generated by HTMLForm itself (not via the descriptor) doesn't have the primary flag and there is no (easy) way to add it, although this generated submit button is most likely the primary one. Add a new function HTMLForm::setSubmitPrimary() to allow a form to set add the primary flag to this submit button. Change-Id: I3ce363f995389a87764edb586b4b64ab2b77b0db --- diff --git a/includes/htmlform/HTMLForm.php b/includes/htmlform/HTMLForm.php index 47200d9b51..48cc828136 100644 --- a/includes/htmlform/HTMLForm.php +++ b/includes/htmlform/HTMLForm.php @@ -167,7 +167,7 @@ class HTMLForm extends ContextSource { protected $mFieldTree; protected $mShowReset = false; protected $mShowSubmit = true; - protected $mSubmitFlag = 'constructive'; + protected $mSubmitFlags = array( 'constructive', 'primary' ); protected $mSubmitCallback; protected $mValidationErrorMessage; @@ -975,7 +975,10 @@ class HTMLForm extends ContextSource { $attribs['class'] = array( 'mw-htmlform-submit' ); if ( $useMediaWikiUIEverywhere ) { - array_push( $attribs['class'], 'mw-ui-button', 'mw-ui-' . $this->mSubmitFlag ); + foreach ( $this->mSubmitFlags as $flag ) { + array_push( $attribs['class'], 'mw-ui-' . $flag ); + } + array_push( $attribs['class'], 'mw-ui-button' ); } $buttons .= Xml::submitButton( $this->getSubmitText(), $attribs ) . "\n"; @@ -1102,7 +1105,7 @@ class HTMLForm extends ContextSource { * @since 1.24 */ public function setSubmitDestructive() { - $this->mSubmitFlag = 'destructive'; + $this->mSubmitFlags = array( 'destructive', 'primary' ); } /** @@ -1110,7 +1113,7 @@ class HTMLForm extends ContextSource { * @since 1.25 */ public function setSubmitProgressive() { - $this->mSubmitFlag = 'progressive'; + $this->mSubmitFlags = array( 'progressive', 'primary' ); } /** diff --git a/includes/htmlform/OOUIHTMLForm.php b/includes/htmlform/OOUIHTMLForm.php index fe2f26eb1d..eec13eeb9b 100644 --- a/includes/htmlform/OOUIHTMLForm.php +++ b/includes/htmlform/OOUIHTMLForm.php @@ -65,7 +65,7 @@ class OOUIHTMLForm extends HTMLForm { $attribs['type'] = 'submit'; $attribs['label'] = $this->getSubmitText(); $attribs['value'] = $this->getSubmitText(); - $attribs['flags'] = array( $this->mSubmitFlag ); + $attribs['flags'] = $this->mSubmitFlags; $buttons .= new OOUI\ButtonInputWidget( $attribs ); } diff --git a/includes/htmlform/VFormHTMLForm.php b/includes/htmlform/VFormHTMLForm.php index c544f161e9..3788379dad 100644 --- a/includes/htmlform/VFormHTMLForm.php +++ b/includes/htmlform/VFormHTMLForm.php @@ -95,8 +95,10 @@ class VFormHTMLForm extends HTMLForm { $attribs['class'] = array( 'mw-htmlform-submit', 'mw-ui-button mw-ui-big mw-ui-block', - 'mw-ui-' . $this->mSubmitFlag, ); + foreach ( $this->mSubmitFlags as $flag ) { + $attribs['class'][] = 'mw-ui-' . $flag; + } $buttons .= Xml::submitButton( $this->getSubmitText(), $attribs ) . "\n"; }