Updating Model Attribute From Inside A Validation Function

Good morning!

I have a validation function which is called via a model rule.

    // from public function rules()



    // validation function

    public function productTypeDependencies($attribute)




            if ($this->$attribute == '' || $this->$attribute == null || $this->$attribute == 0) {

                    $this->addError($attribute, 'Es muss eine Produktart ausgewählt werden.');




    // view   

    <span style="float:left; width:25%;">

            <?php echo $form->labelEx($model,'product_type'); ?>

            <?php echo $form->dropDownList($model,'product_type', $model->getProductType(), array('empty'=>'Produktart ausw&auml;hlen', 'encode' => false, 'style'=>'background-color:GhostWhite; width:100%;')); ?>       

            <?php echo $form->error($model,'product_type'); ?>     



    <span style="float:right; width:50%;">

            <?php echo $form->labelEx($model,'call_number_2'); ?>

            <?php echo $form->textField($model,'call_number_2',array('size'=>35,'maxlength'=>20,'style'=>'background-color:GhostWhite')); ?>

            <?php echo $form->error($model,'call_number_2'); ?>                                    


I would like to set the field call_number_2 in the form calling the validation rule to "YES" when the validation is performed. But, even though the error message is shown, the field does not get updated in the view.

What am I doing wrong?

Thx for your help


Do you have enabled clientside validation in the form?

Try to set this to false.

Are you sure that is performed?

you can use beforeValidate() in model, that is performed alwasy, when the

$model->validate() is called - do you call that??

yes i know the $model->save() call also, but i like to use that

and you dont use $model->save(false) ??

Ajax validation is on.