Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

…d to display array values.
  • Loading branch information...
commit 692390f2f59dac1b06366c9f6a629dc78be6c404 1 parent c6a0623
@resurtm authored
Showing with 10 additions and 0 deletions.
  1. +10 −0 framework/web/helpers/CHtml.php
View
10 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

@resurtm
Owner

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.
Something went wrong with that request. Please try again.