HTMLFormField: Move 'flatlist' handling to fields that use it and document
authorBartosz Dziewoński <matma.rex@gmail.com>
Mon, 8 Aug 2016 20:55:25 +0000 (22:55 +0200)
committerBartosz Dziewoński <matma.rex@gmail.com>
Wed, 24 Aug 2016 15:22:32 +0000 (15:22 +0000)
Change-Id: I5dc6ad71880a741c41757bc64d236971edfbabfa

includes/htmlform/HTMLFormField.php
includes/htmlform/fields/HTMLMultiSelectField.php
includes/htmlform/fields/HTMLRadioField.php

index 8f42ea2..25b4cca 100644 (file)
@@ -455,10 +455,6 @@ abstract class HTMLFormField {
                        $this->mFilterCallback = $params['filter-callback'];
                }
 
-               if ( isset( $params['flatlist'] ) ) {
-                       $this->mClass .= ' mw-htmlform-flatlist';
-               }
-
                if ( isset( $params['hidelabel'] ) ) {
                        $this->mShowEmptyLabels = false;
                }
index 38d231f..c9fcb09 100644 (file)
@@ -10,6 +10,9 @@ class HTMLMultiSelectField extends HTMLFormField implements HTMLNestedFilterable
         *   - dropdown: If given, the options will be displayed inside a dropdown with a text field that
         *     can be used to filter them. This is desirable mostly for very long lists of options.
         *     This only works for users with JavaScript support and falls back to the list of checkboxes.
+        *   - flatlist: If given, the options will be displayed on a single line (wrapping to following
+        *     lines if necessary), rather than each one on a line of its own. This is desirable mostly
+        *     for very short lists of concisely labelled options.
         */
        public function __construct( $params ) {
                parent::__construct( $params );
@@ -18,6 +21,10 @@ class HTMLMultiSelectField extends HTMLFormField implements HTMLNestedFilterable
                if ( isset( $params['dropdown'] ) || strpos( $this->mClass, 'mw-chosen' ) !== false ) {
                        $this->mClass .= ' mw-htmlform-dropdown';
                }
+
+               if ( isset( $params['flatlist'] ) ) {
+                       $this->mClass .= ' mw-htmlform-flatlist';
+               }
        }
 
        function validate( $value, $alldata ) {
index 976befe..f9f035d 100644 (file)
@@ -4,6 +4,21 @@
  * Radio checkbox fields.
  */
 class HTMLRadioField extends HTMLFormField {
+       /**
+        * @param array $params
+        *   In adition to the usual HTMLFormField parameters, this can take the following fields:
+        *   - flatlist: If given, the options will be displayed on a single line (wrapping to following
+        *     lines if necessary), rather than each one on a line of its own. This is desirable mostly
+        *     for very short lists of concisely labelled options.
+        */
+       public function __construct( $params ) {
+               parent::__construct( $params );
+
+               if ( isset( $params['flatlist'] ) ) {
+                       $this->mClass .= ' mw-htmlform-flatlist';
+               }
+       }
+
        function validate( $value, $alldata ) {
                $p = parent::validate( $value, $alldata );