From d23ebca2b9951a9e235562ee49839e7fa79f6d83 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Mon, 8 Aug 2016 22:55:25 +0200 Subject: [PATCH] HTMLFormField: Move 'flatlist' handling to fields that use it and document Change-Id: I5dc6ad71880a741c41757bc64d236971edfbabfa --- includes/htmlform/HTMLFormField.php | 4 ---- includes/htmlform/fields/HTMLMultiSelectField.php | 7 +++++++ includes/htmlform/fields/HTMLRadioField.php | 15 +++++++++++++++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/includes/htmlform/HTMLFormField.php b/includes/htmlform/HTMLFormField.php index 8f42ea2c74..25b4ccacaf 100644 --- a/includes/htmlform/HTMLFormField.php +++ b/includes/htmlform/HTMLFormField.php @@ -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; } diff --git a/includes/htmlform/fields/HTMLMultiSelectField.php b/includes/htmlform/fields/HTMLMultiSelectField.php index 38d231fbc7..c9fcb0992f 100644 --- a/includes/htmlform/fields/HTMLMultiSelectField.php +++ b/includes/htmlform/fields/HTMLMultiSelectField.php @@ -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 ) { diff --git a/includes/htmlform/fields/HTMLRadioField.php b/includes/htmlform/fields/HTMLRadioField.php index 976befe4c2..f9f035d4d7 100644 --- a/includes/htmlform/fields/HTMLRadioField.php +++ b/includes/htmlform/fields/HTMLRadioField.php @@ -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 ); -- 2.20.1