Update OOjs UI to v0.1.0-pre (0fbf6bd14e)
[lhc/web/wiklou.git] / includes / htmlform / HTMLSelectField.php
index 9d719f6..c32b445 100644 (file)
@@ -11,9 +11,9 @@ class HTMLSelectField extends HTMLFormField {
                        return $p;
                }
 
-               $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();
@@ -23,16 +23,6 @@ class HTMLSelectField extends HTMLFormField {
        function getInputHTML( $value ) {
                $select = new XmlSelect( $this->mName, $this->mID, strval( $value ) );
 
-               # If one of the options' 'name' is int(0), it is automatically selected.
-               # because PHP sucks and thinks int(0) == 'some string'.
-               # Working around this by forcing all of them to strings.
-               foreach ( $this->mParams['options'] as &$opt ) {
-                       if ( is_int( $opt ) ) {
-                               $opt = strval( $opt );
-                       }
-               }
-               unset( $opt ); # PHP keeps $opt around as a reference, which is a bit scary
-
                if ( !empty( $this->mParams['disabled'] ) ) {
                        $select->setAttribute( 'disabled', 'disabled' );
                }
@@ -45,7 +35,7 @@ class HTMLSelectField extends HTMLFormField {
                        $select->setAttribute( 'class', $this->mClass );
                }
 
-               $select->addOptions( $this->mParams['options'] );
+               $select->addOptions( $this->getOptions() );
 
                return $select->getHTML();
        }