Good morning!
I have a validation function which is called via a model rule.
// from public function rules()
array('product_type','productTypeDependencies'),
// validation function
public function productTypeDependencies($attribute)
{
$this->call_number_2='YES';
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ählen', 'encode' => false, 'style'=>'background-color:GhostWhite; width:100%;')); ?>
<?php echo $form->error($model,'product_type'); ?>
</span>
<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'); ?>
</span>
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
Hauke