Mwalker has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/52955


Change subject: HTMLForm button behaviour modifications
......................................................................

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
---
M includes/HTMLForm.php
1 file changed, 27 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/55/52955/1

diff --git a/includes/HTMLForm.php b/includes/HTMLForm.php
index 5af813b..c688e21 100644
--- a/includes/HTMLForm.php
+++ b/includes/HTMLForm.php
@@ -128,6 +128,7 @@
 
        protected $mFieldTree;
        protected $mShowReset = false;
+       protected $mShowSubmit = true;
        public $mFieldData;
 
        protected $mSubmitCallback;
@@ -699,7 +700,9 @@
 
                $attribs['class'] = 'mw-htmlform-submit';
 
-               $html .= Xml::submitButton( $this->getSubmitText(), $attribs ) 
. "\n";
+               if ( $this->mShowSubmit ) {
+                       $html .= Xml::submitButton( $this->getSubmitText(), 
$attribs ) . "\n";
+               }
 
                if ( $this->mShowReset ) {
                        $html .= Html::element(
@@ -1036,6 +1039,19 @@
         */
        function suppressReset( $suppressReset = true ) {
                $this->mShowReset = !$suppressReset;
+               return $this;
+       }
+
+       /**
+        * Stop a default submit button being shown for this form. This implies 
that an
+        * alternate submit method must be provided manually.
+        *
+        * @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;
        }
 
@@ -2528,14 +2544,17 @@
        }
 
        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() {

-- 
To view, visit https://gerrit.wikimedia.org/r/52955
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8293a3c09da51152bfc7f6f6951416c71ce0bb38
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Mwalker <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to