Fix for string/int inconsistency in value and option for imagesize, resulting in...
authorAndrew Garrett <werdna@users.mediawiki.org>
Wed, 17 Jun 2009 19:08:14 +0000 (19:08 +0000)
committerAndrew Garrett <werdna@users.mediawiki.org>
Wed, 17 Jun 2009 19:08:14 +0000 (19:08 +0000)
includes/HTMLForm.php

index 04b36da..ba44003 100644 (file)
@@ -601,13 +601,18 @@ class HTMLSelectField extends HTMLFormField {
        }
        
        function getInputHTML( $value ) {               
-               $select = new XmlSelect( $this->mName, $this->mID, $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 things int(0) == 'some string'.
+               //  Working around this by forcing all of them to strings.
+               $options = array_map( 'strval', $this->mParams['options'] );
                
                if (!empty($this->mParams['disabled'])) {
                        $select->setAttribute( 'disabled', 'disabled' );
                }
                
-               $select->addOptions( $this->mParams['options'] );
+               $select->addOptions( $options );
                
                return $select->getHTML();
        }