Yii Ajaxform Validation Only Validates A Part Of The Form

I got a Yii form which collects data for three models. I am using ajaxvalidation, on change and on submit:

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




    'clientOptions' => array(




)); ?>

Now the problem is that that only the first three inputs are getting validated, code of these inputs:


<div class="input-bg wide-input">


                    //fill this field after selecting newspaper

                    echo $form->hiddenField($newspaper, 'id'); ?>

                    <?php echo $form->textField($newspaper, 'name', array('maxlength' => 45, 'placeholder'=>'Krantnaam')); ?>

                    <?php echo $form->error($newspaper, 'name', array('class'=>'error')); ?>


                <a class="button gray-button">Aanbieden</a>

2 and 3:

<div class="input-bg linked-input">

                    <?php echo $form->textField($address, 'postalcode', array('maxlength' => 45, 'placeholder'=>'Postcode')) ?>

                    <?php echo $form->error($address, 'postalcode'); ?>


                <div class="input-bg linked-input">

                    <?php echo $form->textField($address, 'street_number', array('maxlength' => 45, 'placeholder'=>'Huisnummer')); ?>

                    <?php echo $form->error($address, 'street_number'); ?>


Those three inputs serve for two models which are $newspaper and $address. Now the case is that those three inputs are perfectly validated(on change and on submit) where the other seven inputs are not validated, example of one of those inputs that are not validated:

<div class="input-bg linked-input">

            <?php echo $form->textField($offer, 'firstname', array('maxlength' => 45, 'placeholder'=>'Voornaam')); ?>

            <?php echo $form->error($offer, 'firstname'); ?>


Finally, I will post my controller code:

$this->performAjaxValidation($offer, 'offer-form');

$this->performAjaxValidation($address, 'offer-form');

$this->performAjaxValidation($newspaper, 'offer-form');

if(Yii::app()->getRequest()->getIsAjaxRequest()) {

    echo CActiveForm::validate( array($address));  

    echo CActiveForm::validate( array($offer));

    echo CActiveForm::validate( array($newspaper)); 





If I am submitting or changing the form I do get back JSON with the errors for the fields that are not validated on the eye, but they don’t get an error state.

I hope there is someone that can see a mistake or anything else.


Dear Friend

Kindly change the controller logic.

$offer=new Offer;

$newspaper=new Newspaper;

$address=new Address;

if(isset($_POST['ajax']) && $_POST['ajax']==='offer-form')


	echo CActiveForm::validate(array($newspaper,$address,$offer));



//followed by other things.


Thanks, this did the job.