From 4e1ab6e5a5f7e80b4ae25d7b6f5ccbf682cf9e6b Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Fri, 6 Sep 2013 08:40:16 -0400 Subject: [PATCH] Fixes #848: Added hidden field for Html::activeFileInput(). --- framework/yii/helpers/HtmlBase.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/framework/yii/helpers/HtmlBase.php b/framework/yii/helpers/HtmlBase.php index cfff8f5..a93c93e 100644 --- a/framework/yii/helpers/HtmlBase.php +++ b/framework/yii/helpers/HtmlBase.php @@ -1049,7 +1049,10 @@ class HtmlBase */ public static function activeFileInput($model, $attribute, $options = array()) { - return static::activeInput('file', $model, $attribute, $options); + // add a hidden field so that if a model only has a file field, we can + // still use isset($_POST[$modelClass]) to detect if the input is submitted + return static::activeHiddenInput($model, $attribute, array('id' => null, 'value' => '')) + . static::activeInput('file', $model, $attribute, $options); } /**