From: Happy-melon Date: Sat, 18 Dec 2010 19:08:22 +0000 (+0000) Subject: Nicer way of doing r78566, and also one which won't incur Tim's wrath... :D X-Git-Tag: 1.31.0-rc.0~33240 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=e9740b2525c2263c66e7bb5f72168cab20b0bb37;p=lhc%2Fweb%2Fwiklou.git Nicer way of doing r78566, and also one which won't incur Tim's wrath... :D --- diff --git a/includes/HTMLForm.php b/includes/HTMLForm.php index fbb17d4b44..8bed092998 100644 --- a/includes/HTMLForm.php +++ b/includes/HTMLForm.php @@ -1222,16 +1222,18 @@ class HTMLSelectField extends HTMLFormField { # 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( - create_function('$opt', 'return is_int($opt) ? strval($opt) : $opt;'), - $this->mParams['options'] - ); + foreach( $this->mParams['options'] as $key => &$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' ); } - $select->addOptions( $options ); + $select->addOptions( $this->mParams['options'] ); return $select->getHTML(); }