From 029d1bea360a8eb48d08d5b6123041169ec97a2b Mon Sep 17 00:00:00 2001 From: Matt Walker Date: Wed, 20 Mar 2013 17:54:32 -0700 Subject: [PATCH] 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 --- includes/HTMLForm.php | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) 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() { -- 2.20.1