From 20e72c2634b4c3503dddc770fbb74b79bb9818bb Mon Sep 17 00:00:00 2001 From: Andrew Garrett Date: Wed, 29 Jul 2009 16:20:10 +0000 Subject: [PATCH] Fix regression in r53316, some more intelligent handling. --- includes/HTMLForm.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/includes/HTMLForm.php b/includes/HTMLForm.php index 53cf698b16..619a0695a7 100644 --- a/includes/HTMLForm.php +++ b/includes/HTMLForm.php @@ -666,6 +666,14 @@ class HTMLSelectOrOtherField extends HTMLTextField { parent::__construct( $params ); } + + static function forceToStringRecursive( $array ) { + if ( is_array($array) ) { + return array_map( array( __CLASS__, 'forceToStringRecursive' ), $array); + } else { + return strval($array); + } + } function getInputHTML( $value ) { $valInSelect = false; @@ -675,9 +683,11 @@ class HTMLSelectOrOtherField extends HTMLTextField { HTMLFormField::flattenOptions( $this->mParams['options'] ) ); $selected = $valInSelect ? $value : 'other'; + + $opts = self::forceToStringRecursive( $this->mParams['options'] ); $select = new XmlSelect( $this->mName, $this->mID, $selected ); - $select->addOptions( array_map( 'strval', $this->mParams['options'] ) ); + $select->addOptions( $opts ); $select->setAttribute( 'class', 'mw-htmlform-select-or-other' ); -- 2.20.1