Yii 1.1: eactiveform

Enhanced CActiveForm to do client-side javascript validation before sending ajax request


Yii 1.1.1 ~ Yii 1.1.6 This feature has been integrated since version 1.1.7. See CActiveForm


This extension just extend from {link: CActiveForm} using few codes, it enhances the ajax validation.

  • Submit a list of changed attributes to php backend, then can access the attributes list in Controller via $_POST['attributes']['ModelName'] and verify these attributes only.
  • First to do client-side javascript validations before submission of ajax, and js validators converted from {link: CValidator} automatically.


Using this extension is same as original CActiveForm.

$form = $this->beginWidget('ext.EActiveForm');
// as same as normal CActiveForm codes

Controller example codes for verifying modified attributes only:

protected function performAjaxValidation($model)
  if (Yii::app()->request->isAjaxRequest && isset($_POST['ajax']))
    $class = get_class($model);
    if (isset($_POST['attributes']) && is_array($_POST['attributes'][$class]))
      $attributes = $_POST['attributes'][$class];
      $attributes = null;
    echo CActiveForm::validate($model, $attributes);


Nov 28, 2010

  • New version number 1.2
  • Enable ajax validation bye default(Override the property enableAjaxValidation)
  • Fixed issue on radiolist (thanks to ianare's report)
  • Fixed issue on incorrectly update error message for attributes when validate on submit.

Nov 14, 2010

  • New version number 1.1
  • Strict inspection validator is completely converted.
  • Add CTypeValidator support


For CRegualarExpressionValidator, please make sure Javascript compatible.

Reporting Issue:

Reporting Issues and comments are welcome, plz report them to offical extension page of Yii. Report issue

Total 7 comments

#7105 report it
jakub at 2012/02/23 05:45pm
1.2.tgz corrupt

Your 1.2.tgz is corrupt, but the .zip file is OK.

#3254 report it
hightman at 2011/03/29 01:39am
The feature has been integrated since version 1.1.7

As the title, thanks to Qiang.

The extension now only need for the Yii older than version 1.1.7

#2221 report it
hightman at 2010/11/28 09:08am
to ianare

thanks for your report, I have fixed it. Because I just used validateOnChange, so I haven't found this problem before.

#2216 report it
ianaré at 2010/11/27 04:26pm
Problem with radiolists

Great extension, a real time saver and takes a load off the server ;-)

One problem though : it will not properly validate radiolist items. This is because it will not look for the value in the 'name' attribute but in 'id', which isn't identical to id for the case of radio lists.


#2167 report it
hightman at 2010/11/21 01:18am
to hung5s

I think it will be better to set the default value of public property enableAjaxValidation true, as follow:

class EActiveForm extends CACtiveForm
    public $enableAjaxValidation = true;
    public $attributesVar = 'attributes';
#2138 report it
Hudson Nguyen at 2010/11/17 03:21am
Great! thanks

This is just great ! Thanks a lot.

I added public function init(){ $this->enableAjaxValidation = true; $this->clientOptions['validateOnSubmit'] = true; } because only reason i change Yii generated code to EActiveForm is js validation and it needs the options.

#2116 report it
hightman at 2010/11/13 01:56pm
Supported Validators

'CRequiredValidator','CRegularExpressionValidator', 'CEmailValidator','CUrlValidator','CCompareValidator', 'CStringValidator','CRangeValidator','CNumberValidator', 'CBooleanValidator'

Leave a comment

Please to leave your comment.

Create extension