Reputation: 321
i am trying to disable a field on update rules models but i am having error.
i try like:
array('date', 'constraint', 'readOnly'=>true, 'on'=>'update'),
but i am having this error:
"include(constraint.php): failed to open stream: No such file or directory"
I can disable from view using htmloptions but i need do it from model because on update i need to disable more than 5 fields.
how could i do this?
thx in advance
Upvotes: 0
Views: 6417
Reputation: 8950
You are declaring a rule with a validator that doesn't exist, so it's normal that you have an error:
array('date', 'constraint', 'readOnly'=>true, 'on'=>'update'),
This line is doing the following: apply the validator constraint
on the date
field on update
scenario with param readOnly
set to true
.
The validator constraint
doesn't exists has a built in functonnality in Yii so if you havn't created it then it doesn't exist!
Documentation:
Edit: In your form you could do something like:
<?php
echo $form->textField(
$model,
'email',
array('readonly'=>($model->scenario == 'update')? true : false)
);
?>
As you can see the readonly value will depend on the scenario.
Upvotes: 5