OOUIHTMLForm: Implement HTMLRadioField
authorBartosz Dziewoński <matma.rex@gmail.com>
Sun, 14 Jun 2015 18:17:09 +0000 (20:17 +0200)
committerBartosz Dziewoński <matma.rex@gmail.com>
Sat, 27 Jun 2015 13:38:04 +0000 (13:38 +0000)
Example usage in I2c3d6486e09b3e4d5537b95194e178fd73ac9792
(Special:PageLanguage). Trivial now that we have RadioSelectInputWidget
in OOUI (added in fd2815e372f6a4beb4f4e5f2a7d9cbf785d40851).

Depends on If68f04a2fa20e7c03763898ab80cf39b5e6cb182 in OOUI.

Bug: T98855
Change-Id: I224e591e58534c07af62eebb9ae4b185225edc33

includes/htmlform/HTMLRadioField.php

index 0f00540..19b45be 100644 (file)
@@ -38,6 +38,23 @@ class HTMLRadioField extends HTMLFormField {
                return $html;
        }
 
+       function getInputOOUI( $value ) {
+               $options = array();
+               foreach ( $this->getOptions() as $label => $value ) {
+                       $options[] = array(
+                               'data' => $value,
+                               'label' => $this->mOptionsLabelsNotFromMessage ? new OOUI\HtmlSnippet( $label ) : $label,
+                       );
+               }
+
+               return new OOUI\RadioSelectInputWidget( array(
+                       'name' => $this->mName,
+                       'value' => $value,
+                       'options' => $options,
+                       'classes' => 'mw-htmlform-flatlist-item',
+               ) + $this->getAttributes( array( 'disabled', 'tabindex' ), array( 'tabindex' => 'tabIndex' ) ) );
+       }
+
        function formatOptions( $options, $value ) {
                $html = '';