HTMLForm: Handle Flags in non-OOUI form buttons, too
authorFlorian <florian.schmidt.stargatewissen@gmail.com>
Thu, 9 Jul 2015 17:08:21 +0000 (19:08 +0200)
committerFlorian <florian.schmidt.stargatewissen@gmail.com>
Sat, 11 Jul 2015 14:01:12 +0000 (16:01 +0200)
Flags added to a button or submit field in a non-OOUI form will be
handled now, too.

With activated wgUseMediaWikiUIEverywhere:
All flags will get the 'mw-ui-' prefix.
(mw-ui-button is added to the button automatically)

With deactivated wgUseMediaWikiUIEverywhere:
All flags will get the 'mw-htmlform-' prefix.

This allows HTMLForm users to add flags to only the button, without
setting them as a cssclas, which would be added to the wrapper elements,
too.

Bug: T102838
Change-Id: I121a966fb4db6649a6e1012187148d354b5534f0

includes/htmlform/HTMLButtonField.php

index afd7cf6..8d7aec3 100644 (file)
@@ -21,8 +21,20 @@ class HTMLButtonField extends HTMLFormField {
        }
 
        public function getInputHTML( $value ) {
+               $flags = '';
+               $prefix = 'mw-htmlform-';
+               if ( $this->mParent instanceof VFormHTMLForm ||
+                       $this->mParent->getConfig()->get( 'UseMediaWikiUIEverywhere' )
+               ) {
+                       $prefix = 'mw-ui-';
+                       // add mw-ui-button separately, so the descriptor doesn't need to set it
+                       $flags .= $prefix.'button';
+               }
+               foreach ( $this->mFlags as $flag ) {
+                       $flags .= ' ' . $prefix . $flag;
+               }
                $attr = array(
-                       'class' => 'mw-htmlform-submit ' . $this->mClass,
+                       'class' => 'mw-htmlform-submit ' . $this->mClass . $flags,
                        'id' => $this->mID,
                ) + $this->getAttributes( array( 'disabled', 'tabindex' ) );