Correct button colours of preference page when $wgUseMediaWikiUIEverywhere is enabled
[lhc/web/wiklou.git] / includes / htmlform / HTMLForm.php
index fc2222a..d582da3 100644 (file)
@@ -139,6 +139,7 @@ class HTMLForm extends ContextSource {
        protected $mFieldTree;
        protected $mShowReset = false;
        protected $mShowSubmit = true;
+       protected $mSubmitModifierClass = 'mw-ui-constructive';
 
        protected $mSubmitCallback;
        protected $mValidationErrorMessage;
@@ -473,6 +474,9 @@ class HTMLForm extends ContextSource {
                        if ( !empty( $field->mParams['nodata'] ) ) {
                                continue;
                        }
+                       if ( $field->isHidden( $this->mFieldData ) ) {
+                               continue;
+                       }
                        if ( $field->validate(
                                        $this->mFieldData[$fieldname],
                                        $this->mFieldData )
@@ -894,7 +898,7 @@ class HTMLForm extends ContextSource {
                        $attribs['class'] = array( 'mw-htmlform-submit' );
 
                        if ( $this->isVForm() || $useMediaWikiUIEverywhere ) {
-                               array_push( $attribs['class'], 'mw-ui-button', 'mw-ui-constructive' );
+                               array_push( $attribs['class'], 'mw-ui-button', $this->mSubmitModifierClass );
                        }
 
                        if ( $this->isVForm() ) {
@@ -936,12 +940,15 @@ class HTMLForm extends ContextSource {
                                $attrs['id'] = $button['id'];
                        }
 
-                       if ( $useMediaWikiUIEverywhere ) {
+                       if ( $this->isVForm() || $useMediaWikiUIEverywhere ) {
                                if ( isset( $attrs['class'] ) ) {
                                        $attrs['class'] .= ' mw-ui-button';
                                } else {
                                        $attrs['class'] = 'mw-ui-button';
                                }
+                               if ( $this->isVForm() ) {
+                                       $attrs['class'] .= ' mw-ui-big mw-ui-block';
+                               }
                        }
 
                        $buttons .= Html::element( 'input', $attrs ) . "\n";
@@ -1036,6 +1043,14 @@ class HTMLForm extends ContextSource {
                return $this;
        }
 
+       /**
+        * Identify that the submit button in the form has a destructive action
+        *
+        */
+       public function setSubmitDestructive() {
+               $this->mSubmitModifierClass = 'mw-ui-destructive';
+       }
+
        /**
         * Set the text for the submit button to a message
         * @since 1.19