Answer the question
In order to leave comments, you need to log in
How to block input for one of the views?
Hello! Can you please tell me how it would be correct to write a condition in ActiveForm so that in the form of create the input field has the disabled status, and for the update types the field has already been unlocked?
Answer the question
In order to leave comments, you need to log in
If you are editing an ActiveRecord, then it has a "property" isNewRecord:
echo $form->field($model, 'attributeName')->input('text', ['disabled' => $model->isNewRecord]);
class MyModel extends Model {
// ...
public function getIsNew(): bool
{
// some logic behind it
}
}
echo $form->field($model, 'attributeName')->input('text', ['disabled' => $model->isNew]);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question