From e9740b2525c2263c66e7bb5f72168cab20b0bb37 Mon Sep 17 00:00:00 2001 From: Happy-melon Date: Sat, 18 Dec 2010 19:08:22 +0000 Subject: [PATCH] Nicer way of doing r78566, and also one which won't incur Tim's wrath... :D --- includes/HTMLForm.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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(); } -- 2.20.1