Merge "Add two hooks to allow for extensions to expose log_search values in the UI"
[lhc/web/wiklou.git] / includes / htmlform / HTMLRadioField.php
index f206ed6..8765407 100644 (file)
@@ -15,9 +15,9 @@ class HTMLRadioField extends HTMLFormField {
                        return false;
                }
 
-               $validOptions = HTMLFormField::flattenOptions( $this->mParams['options'] );
+               $validOptions = HTMLFormField::flattenOptions( $this->getOptions() );
 
-               if ( in_array( $value, $validOptions ) ) {
+               if ( in_array( strval( $value ), $validOptions, true ) ) {
                        return true;
                } else {
                        return $this->msg( 'htmlform-select-badoption' )->parse();
@@ -28,12 +28,12 @@ class HTMLRadioField extends HTMLFormField {
         * This returns a block of all the radio options, in one cell.
         * @see includes/HTMLFormField#getInputHTML()
         *
-        * @param $value String
+        * @param string $value
         *
-        * @return String
+        * @return string
         */
        function getInputHTML( $value ) {
-               $html = $this->formatOptions( $this->mParams['options'], $value );
+               $html = $this->formatOptions( $this->getOptions(), strval( $value ) );
 
                return $html;
        }
@@ -42,6 +42,7 @@ class HTMLRadioField extends HTMLFormField {
                $html = '';
 
                $attribs = $this->getAttributes( array( 'disabled', 'tabindex' ) );
+               $elementFunc = array( 'Html', $this->mOptionsLabelsNotFromMessage ? 'rawElement' : 'element' );
 
                # @todo Should this produce an unordered list perhaps?
                foreach ( $options as $label => $info ) {
@@ -50,8 +51,8 @@ class HTMLRadioField extends HTMLFormField {
                                $html .= $this->formatOptions( $info, $value );
                        } else {
                                $id = Sanitizer::escapeId( $this->mID . "-$info" );
-                               $radio = Xml::radio( $this->mName, $info, $info == $value, $attribs + array( 'id' => $id ) );
-                               $radio .= ' ' . Html::rawElement( 'label', array( 'for' => $id ), $label );
+                               $radio = Xml::radio( $this->mName, $info, $info === $value, $attribs + array( 'id' => $id ) );
+                               $radio .= ' ' . call_user_func( $elementFunc, 'label', array( 'for' => $id ), $label );
 
                                $html .= ' ' . Html::rawElement(
                                        'div',