From 39817de33003df2036b083abf4f51a7862c2a16c Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Wed, 24 Jul 2013 08:02:19 -0400 Subject: [PATCH] Ensure correct type. --- framework/yii/helpers/HtmlBase.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/framework/yii/helpers/HtmlBase.php b/framework/yii/helpers/HtmlBase.php index 29dfaba..c9d9db0 100644 --- a/framework/yii/helpers/HtmlBase.php +++ b/framework/yii/helpers/HtmlBase.php @@ -553,7 +553,7 @@ class HtmlBase */ public static function radio($name, $checked = false, $options = array()) { - $options['checked'] = $checked; + $options['checked'] = (boolean)$checked; $value = array_key_exists('value', $options) ? $options['value'] : '1'; if (isset($options['uncheck'])) { // add a hidden field so that if the radio button is not selected, it still submits a value @@ -582,7 +582,7 @@ class HtmlBase */ public static function checkbox($name, $checked = false, $options = array()) { - $options['checked'] = $checked; + $options['checked'] = (boolean)$checked; $value = array_key_exists('value', $options) ? $options['value'] : '1'; if (isset($options['uncheck'])) { // add a hidden field so that if the checkbox is not selected, it still submits a value @@ -1288,7 +1288,7 @@ class HtmlBase $attrs = isset($options[$key]) ? $options[$key] : array(); $attrs['value'] = (string)$key; $attrs['selected'] = $selection !== null && - (!is_array($selection) && !strcmp($key, $selection) + (!is_array($selection) && !strcmp($key, $selection) || is_array($selection) && in_array($key, $selection)); $lines[] = static::tag('option', str_replace(' ', ' ', static::encode($value)), $attrs); }