Permalink
Browse files

CHtml::activeInputField() and CHtml::activeTextField() is not intende…

…d to display array values.
  • Loading branch information...
1 parent c6a0623 commit 692390f2f59dac1b06366c9f6a629dc78be6c404 @resurtm committed Mar 10, 2013
Showing with 10 additions and 0 deletions.
  1. +10 −0 framework/web/helpers/CHtml.php
@@ -1574,6 +1574,11 @@ public static function activeTextArea($model,$attribute,$htmlOptions=array())
}
else
$text=self::resolveValue($model,$attribute);
+
+ // https://github.com/yiisoft/yii/issues/1955
+ if(is_array($text))
+ $text='';
+
return self::tag('textarea',$htmlOptions,isset($htmlOptions['encode']) && !$htmlOptions['encode'] ? $text : self::encode($text));
}
@@ -2137,6 +2142,11 @@ protected static function activeInputField($type,$model,$attribute,$htmlOptions)
unset($htmlOptions['value']);
elseif(!isset($htmlOptions['value']))
$htmlOptions['value']=self::resolveValue($model,$attribute);
+
+ // https://github.com/yiisoft/yii/issues/1955
+ if(is_array($htmlOptions['value']))
+ $htmlOptions['value']='';
+
if($model->hasErrors($attribute))
self::addErrorCss($htmlOptions);
return self::tag('input',$htmlOptions);

1 comment on commit 692390f

Owner

resurtm commented on 692390f Mar 10, 2013

There is another moment: even if we'll change validators, calling CActiveForm's or CHtml's methods in a views would cause array to string conversion errors. In my opinion this case should be handled here.

Please sign in to comment.