From: Matt Walker Date: Sat, 9 Mar 2013 01:30:49 +0000 (-0800) Subject: HTMLForm button behaviour modifications X-Git-Tag: 1.31.0-rc.0~20105 X-Git-Url: http://git.cyclocoop.org/data/Luca_Pacioli_%28Gemaelde%29.jpeg?a=commitdiff_plain;h=4e3e636a7c91da6571e362d15d1010f42876674d;p=lhc%2Fweb%2Fwiklou.git HTMLForm button behaviour modifications - Buttons can now be marked disabled and they will not be clickable. - The default submit button may now be opted out of. Change-Id: I8293a3c09da51152bfc7f6f6951416c71ce0bb38 --- diff --git a/includes/HTMLForm.php b/includes/HTMLForm.php index 816ea16c08..e2040871f0 100644 --- a/includes/HTMLForm.php +++ b/includes/HTMLForm.php @@ -128,6 +128,7 @@ class HTMLForm extends ContextSource { protected $mFieldTree; protected $mShowReset = false; + protected $mShowSubmit = true; public $mFieldData; protected $mSubmitCallback; @@ -683,23 +684,26 @@ class HTMLForm extends ContextSource { */ function getButtons() { $html = ''; - $attribs = array(); - if ( isset( $this->mSubmitID ) ) { - $attribs['id'] = $this->mSubmitID; - } + if ( $this->mShowSubmit ) { + $attribs = array(); - if ( isset( $this->mSubmitName ) ) { - $attribs['name'] = $this->mSubmitName; - } + if ( isset( $this->mSubmitID ) ) { + $attribs['id'] = $this->mSubmitID; + } - if ( isset( $this->mSubmitTooltip ) ) { - $attribs += Linker::tooltipAndAccesskeyAttribs( $this->mSubmitTooltip ); - } + if ( isset( $this->mSubmitName ) ) { + $attribs['name'] = $this->mSubmitName; + } - $attribs['class'] = 'mw-htmlform-submit'; + if ( isset( $this->mSubmitTooltip ) ) { + $attribs += Linker::tooltipAndAccesskeyAttribs( $this->mSubmitTooltip ); + } + + $attribs['class'] = 'mw-htmlform-submit'; - $html .= Xml::submitButton( $this->getSubmitText(), $attribs ) . "\n"; + $html .= Xml::submitButton( $this->getSubmitText(), $attribs ) . "\n"; + } if ( $this->mShowReset ) { $html .= Html::element( @@ -851,6 +855,21 @@ class HTMLForm extends ContextSource { return $this; } + /** + * Stop a default submit button being shown for this form. This implies that an + * alternate submit method must be provided manually. + * + * @since 1.22 + * + * @param bool $suppressSubmit Set to false to re-enable the button again + * + * @return HTMLForm $this for chaining calls + */ + function suppressDefaultSubmit( $suppressSubmit = true ) { + $this->mShowSubmit = !$suppressSubmit; + return $this; + } + /** * @param string $id DOM id for the form * @return HTMLForm $this for chaining calls (since 1.20) @@ -2526,14 +2545,17 @@ class HTMLSubmitField extends HTMLFormField { } public function getInputHTML( $value ) { - return Xml::submitButton( - $value, - array( - 'class' => 'mw-htmlform-submit ' . $this->mClass, - 'name' => $this->mName, - 'id' => $this->mID, - ) + $attr = array( + 'class' => 'mw-htmlform-submit ' . $this->mClass, + 'name' => $this->mName, + 'id' => $this->mID, ); + + if ( !empty( $this->mParams['disabled'] ) ) { + $attr['disabled'] = 'disabled'; + } + + return Xml::submitButton( $value, $attr ); } protected function needsLabel() {