Avoid default validation if others fails

Hi everyone

I facing trouble with validation for default.Validation works fine but whenever other validations fails also default validator sets if field is empty then it sets default value.its fine but whenever it throws errors it fills the form using default values which are specified in model.I want to avoid this, it should work only when validations are true. otherwise it should keep empty values instead specified default values.


Can you specify which form field all or some ?? and can you provide some code of the form you have problem??


here my code:


<div class="row">

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

        <?php echo $form->radioButton($model, 'started', array('uncheckValue' => NULL, 'value' => '1')); ?> Yes

        <?php echo $form->radioButton($model, 'started', array('uncheckValue' => NULL, 'value' => '0')); ?> No


    <div class="row">

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

        <?php echo $form->radioButton($model, 'acl_group_enable', array('uncheckValue' => NULL, 'value' => '1')); ?> Enable

        <?php echo $form->radioButton($model, 'acl_group_enable', array('uncheckValue' => NULL, 'value' => '0')); ?> Disable


In the above code started is mandatory field and acl_group_enable is optional.

In model i wrote code like below in rules() function.


array('acl_group_enable','default','setOnEmpty'=> TRUE,'value'=>'0');

For the above code:

  1. When i haven’t selected started option it throws error but i haven’t selected acl_group_enable, but according to the above validation code it shows error for started but acl_group_enable is selecting disable option automatically.

My requirement is whenever any errors throws from model it should not work on default validator/it should fill with previous values.