CActiveForm ajax does not work

I have added ‘enableAjaxValidation’ => true to my ‘CActiveForm’ widget.

And updated my controler etc.

But when i submit my form or type something in the input fields i can’t detect the ajax parameter in the post headers or don’t see callbacks for validations (i’m using firebug)

So anybody a clue why this issent working?

Here is a code overview:

View:




        <?php

        $form = $this->beginWidget('CActiveForm', array(

                    'enableAjaxValidation' => true,

                    'id' => 'CallMe-form',    


                ));

        $errors = $form->errorSummary($modelCallMe);

        ?>

        <p>Vul hieronder uw gegevens in, dan neem ik zo

            spoedig mogelijk contact op.</p>

<?php

        echo $form->labelEx($modelCallMe, 'name');

        echo $form->textField($modelCallMe, 'name');


        echo $form->labelEx($modelCallMe, 'telephone');

        echo $form->textField($modelCallMe, 'telephone');


//Own made button

        echo Button::submitButton('Verzenden', $form->id);


        $this->endWidget();

        

        if (Yii::app()->user->hasFlash('callme')):

            echo Yii::app()->user->getFlash('callme');

        endif;

?>



Controller:





        $callmeModel = new CallMe;

        $this->performAjaxValidation($callmeModel, 'CallMe-form');

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

            $callmeModel->attributes = $_POST['CallMe'];

            if ($callmeModel->save()) {

                $headers = "From: no-reply@zinet-solutions.be";

                //mail(Yii::app()->params['adminEmail'],'Call Me - verzonden vanaf Zinet Solutions',$model->name.'\n'.$model->telephone,$headers);

                Yii::app()->user->setFlash('callme', 'Hartelijk bedankt. Wij bellen u zo snel als mogelijk op.');

            }

        }



Frontcontroller:




    protected function performAjaxValidation($model, $formId) {

        if (isset($_POST['ajax']) && $_POST['ajax'] === $formId) {

            echo CActiveForm::validate($model);

            Yii::app()->end();

        }

    }



Model




class CallMe extends CActiveRecord {


    public static function model($className=__CLASS__) {

        return parent::model($className);

    }


    /**

     * @return string the associated database table name

     */

    public function tableName() {

        return '{{callme}}';

    }


    public function rules() {

        return array(

            // name, email, subject and body are required

            array('name, telephone', 'required'),

        );

    }


    /*

      public function relations() {


      }

     */


    /**

     * @return array customized attribute labels (name=>label)

     */

    public function attributeLabels() {

        return array(

            'id' => 'Id',

            'name' => 'Naam',

            'telephone' => 'Telefoon'

        );

    }


}



Allright here is the solution:

When you want to use ajax Validation you have to add the error message as well.

Else the callback for the validation will not be triggerd.

In my case:


echo $form->error($modelCallMe, 'name');