ok I have this rule
array('accountID', 'required', 'on' => 'create'),
that is only during account creation this field should be enabled but during user update this field can be edited. Where I am making mistake?
ok I have this rule
array('accountID', 'required', 'on' => 'create'),
that is only during account creation this field should be enabled but during user update this field can be edited. Where I am making mistake?
What do you mean disable? You can set unsafe validation rule if you don`t want to assign something for it.
@prat: You want set the textfield in the update-form on read-only, don’t you? The validation-Rules just test if your input is correct, but it can’t set the textfield to read-only.
A quick solution could be:
your _form.php will be rendered by create and update:
<?php echo $this->renderPartial('_form',
array(
'model'=>model,
)); ?>
Now modify the call of renderPartial. Set a bool-variable and send it to your _form.php, for example in this way:
create.php
<?php
$bool_var = true;
echo $this->renderPartial('_form',
array(
'model'=>$model,
'justInCreateForm'=>$bool_var,
));
?>
update.php
<?php
$bool_var = false;
echo $this->renderPartial('_form',
array(
'model'=>$model,
'justInCreateForm'=>$bool_var,
));
?>
Now, in your _form.php, you can use the variable $justInCreateForm. Depending on this variable, you can set the textfield to readonly.
That’s not a nice solution, but it will help you.
Best regards,
Riff
Hi no needed any code just write a three line
<?php if ($this->getAction()->id == 'create'): ?>
//without readonly
<?else:?>
//read only set
<?php endif; ?>