Adding css styling option for help option in HTMLForm
authorDerric Atzrott <datzrott@alizeepathology.com>
Wed, 16 Jul 2014 13:38:37 +0000 (09:38 -0400)
committerBrian Wolff <bawolff+wn@gmail.com>
Wed, 16 Jul 2014 23:17:07 +0000 (20:17 -0300)
There is now a new option named csshelpclass that can be passed in form
descriptors for HTMLForm objects.  This option accepts a css class and
applies it to the help text that is provided with the help option in the
form descriptor.

Bug: 65087
Change-Id: If1bd1d12a9159895f45c9cf0fbb7992e4c7e3526

includes/htmlform/HTMLForm.php
includes/htmlform/HTMLFormField.php

index 3334694..df6582c 100644 (file)
@@ -50,6 +50,7 @@
  *    'default'             -- default value when the form is displayed
  *    'id'                  -- HTML id attribute
  *    'cssclass'            -- CSS class
+ *    'csshelpclass'        -- CSS class used to style help text
  *    'options'             -- associative array mapping labels to values.
  *                             Some field types support multi-level arrays.
  *    'options-messages'    -- associative array mapping message keys to values.
index 8076e8a..1fcc866 100644 (file)
@@ -13,6 +13,7 @@ abstract class HTMLFormField {
        protected $mLabel; # String label.  Set on construction
        protected $mID;
        protected $mClass = '';
+       protected $mHelpClass = false;
        protected $mDefault;
        protected $mOptions = false;
        protected $mOptionsLabelsNotFromMessage = false;
@@ -397,6 +398,10 @@ abstract class HTMLFormField {
                        $this->mClass = $params['cssclass'];
                }
 
+               if ( isset( $params['csshelpclass'] ) ) {
+                       $this->mHelpClass = $params['csshelpclass'];
+               }
+
                if ( isset( $params['validation-callback'] ) ) {
                        $this->mValidationCallback = $params['validation-callback'];
                }
@@ -562,7 +567,11 @@ abstract class HTMLFormField {
                        $rowAttributes['class'] = 'mw-htmlform-hide-if';
                }
 
-               $row = Html::rawElement( 'td', array( 'colspan' => 2, 'class' => 'htmlform-tip' ), $helptext );
+               $tdClasses = array( 'htmlform-tip' );
+               if ( $this->mHelpClass !== false ) {
+                       $tdClasses[] = $this->mHelpClass;
+               }
+               $row = Html::rawElement( 'td', array( 'colspan' => 2, 'class' => $tdClasses ), $helptext );
                $row = Html::rawElement( 'tr', $rowAttributes, $row );
 
                return $row;