From: Matt Walker Date: Thu, 21 Mar 2013 00:54:32 +0000 (-0700) Subject: HTMLForms: Support non submit buttons X-Git-Tag: 1.31.0-rc.0~19907 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/membres/message.php?a=commitdiff_plain;h=029d1bea360a8eb48d08d5b6123041169ec97a2b;p=lhc%2Fweb%2Fwiklou.git HTMLForms: Support non submit buttons There is now a new generic HTMLButtonField class which does not need to be a submit button. Change-Id: I451a952bba0c7339b5337e5201417beaee3f16fd --- diff --git a/includes/HTMLForm.php b/includes/HTMLForm.php index b7bdcfd20c..2d0cefc5c9 100644 --- a/includes/HTMLForm.php +++ b/includes/HTMLForm.php @@ -2542,7 +2542,19 @@ class HTMLHiddenField extends HTMLFormField { * Add a submit button inline in the form (as opposed to * HTMLForm::addButton(), which will add it at the end). */ -class HTMLSubmitField extends HTMLFormField { +class HTMLSubmitField extends HTMLButtonField { + protected $buttonType = 'submit'; +} + +/** + * Adds a generic button inline to the form. Does not do anything, you must add + * click handling code in JavaScript. Use a HTMLSubmitField if you merely + * wish to add a submit button to a form. + * + * @since 1.22 + */ +class HTMLButtonField extends HTMLFormField { + protected $buttonType = 'button'; public function __construct( $info ) { $info['nodata'] = true; @@ -2552,7 +2564,6 @@ class HTMLSubmitField extends HTMLFormField { public function getInputHTML( $value ) { $attr = array( 'class' => 'mw-htmlform-submit ' . $this->mClass, - 'name' => $this->mName, 'id' => $this->mID, ); @@ -2560,7 +2571,12 @@ class HTMLSubmitField extends HTMLFormField { $attr['disabled'] = 'disabled'; } - return Xml::submitButton( $value, $attr ); + return Html::input( + $this->mName, + $value, + $this->buttonType, + $attr + ); } protected function needsLabel() {