From 79632bf1632d1a29b5520d01d59cbb31278cb890 Mon Sep 17 00:00:00 2001 From: "qiang.xue" Date: Mon, 1 Nov 2010 21:17:02 +0000 Subject: [PATCH] (Fixes issue 1651) --- CHANGELOG | 1 + framework/web/js/source/jquery.yiiactiveform.js | 2 ++ framework/web/widgets/CActiveForm.php | 7 ++++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index fcb19c0b23..6d1df4e56c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -33,6 +33,7 @@ Version 1.1.5 to be released - Enh #1618: Fixed CHttpRequest::getAcceptTypes() to make sure it works even if HTTP_ACCEPT is not defined (Y!!) - Enh #1627: Added check if FreeType support is installed and enabled in GD (mdomba) - Enh #1641: Added PhpUnit 3.5.0RC1 and up support (Sam Dark) +- Enh #1651: Added 'name' and 'model' properties to the attribute objects used in CActiveForm javascript code (Qiang) - Enh #1661: Added CActiveForm 'reset' event handler to reset validation errors if using CHtml::resetButton() (mdomba) - Enh #1667: Added CDbCriteria::index to support indexing the AR query result array with the specified attribute values (Qiang) - Enh #1668: Added validation to ensure PHP keywords be not used as class names (Qiang) diff --git a/framework/web/js/source/jquery.yiiactiveform.js b/framework/web/js/source/jquery.yiiactiveform.js index 8223c8c2a8..ab5e58dccd 100644 --- a/framework/web/js/source/jquery.yiiactiveform.js +++ b/framework/web/js/source/jquery.yiiactiveform.js @@ -312,6 +312,8 @@ /** * list of attributes to be validated. Each array element is of the following structure: * { + * model : 'ModelClass', // the model class name + * name : 'name', // attribute name * inputID : 'input-tag-id', * errorID : 'error-tag-id', * value : undefined, diff --git a/framework/web/widgets/CActiveForm.php b/framework/web/widgets/CActiveForm.php index 16dee68b57..102cc6d0a1 100644 --- a/framework/web/widgets/CActiveForm.php +++ b/framework/web/widgets/CActiveForm.php @@ -354,7 +354,12 @@ public function error($model,$attribute,$htmlOptions=array(),$enableAjaxValidati if(!isset($htmlOptions['id'])) $htmlOptions['id']=$inputID.'_em_'; - $option=array('inputID'=>$inputID, 'errorID'=>$htmlOptions['id']); + $option=array( + 'inputID'=>$inputID, + 'errorID'=>$htmlOptions['id'], + 'model'=>get_class($model), + 'name'=>$attribute, + ); $optionNames=array( 'validationDelay',