enableClientValidation not working

I’m having difficulty getting automatic client validation to work. I’m not the only person working on this project, so there’s a chance something has been damaged, removed, etc. without my knowledge. However, the framework itself should be intact.

In summary, this is what I have in the Controller for the action in question:

    public function actionPresentation() {

        $model = new PresentationForm;


        if (isset($_POST['PresentationForm']))


            $model->attributes = $_POST['PresentationForm'];

            if ($model->validate()) {

                $result = Mail::sendFormModel($model);





        $this->render('presentation', array('model'=>$model));


    // Incomplete

    public function handleAjaxValidation($model) {

        if (isset($_POST['ajax'])) {

            echo $_POST['ajax'];




Here is what I have in the view.

    <?php $form=$this->beginWidget('ActiveForm', array(





    )); ?>

I load the page and focus works. In the source, the jquery script file is sourced, but not the yiiactiveform script file. No client validation seems to happen. Also, I have enableAjaxValidation on too, which I have not fully implemented in the Controller, but it does not seem to even try anyway. In the framework, I only find that yiiactiveform script mentioned once. It’s in the run() method of framework/web/widgets/CActiveForm.php. Here is the code:

    public function run()




        echo CHtml::endForm();


        if(!$this->enableAjaxValidation && !$this->enableClientValidation || empty($this->attributes))













        if(isset($this->clientOptions['validationUrl']) && is_array($this->clientOptions['validationUrl']))












I did some debugging and found that empty($this->attributes) ends up being true. This makes me wonder if I’m doing something wrong, but thus far have not found an answer, despite asking around.

So, any help would be greatly appreciated!

Scan Activeform.php for changes that may affect ajax validation.


It only overrides init() to register form.css. It also calls parent::init().

Check if scriptMap (or packages) are defined/redefined somewhere.


The strings ‘scriptMap’ and ‘packages’ do not appear anywhere in the application directory (just in the framework, which has not been altered). Does that rule this out, or is there something else I can look at? I’m not familiar with scriptMap or how the packages work.

If yiiactiveform js code is not included in the page then client validation and ajax validation will not work as that is processed from there… you need to find the reason why that file is not registerd…

If you can try to use CActiveForm to see if the script will be included in the generated page…

If not… then check with other developers to see who and why did disable the yiiactiveofrm js code…

Yes, that’s why I’m here.

The same problem exists when using CActiveForm.

No one disabled it intentionally, but it is possible something was changed that inadvertently caused this problem. If you have any ideas on what this might be, I’d be happy to investigate it.

Unfortunately, the problem is still there and I have yet to find a solution.

I recommend some structure to your approach. We don’t really have enough information, so you’ll need to go in and narrow things down.

First, you should try to rule out problems in the core framework. Redownload it, replace it, and see if that works. (Or better yet, make sure no one changed anything in the core!)

Second, you need to narrow it down to that specific controller/model/view or the base controller/model/view. Create a new test table (ie, with two fields such as "id" and "name"), and then create the model + crud for it using gii and see if that works. If it works, then the base controller/model/view is fine.

I have appeared in this issue,you have to ensure the following:

  1. echo $form->error($[size=2]model,’[/size][color=#008800][size=2]firstName[/size][/color][size=2]’[/size]) : you have to use this sentence in your view (directly),it will bind the CActiveFom’s attributes property!

2.The above sentence must be placed in front of "<?php $this->endWidget(); ?>"!