yii\bootstrap\ActiveForm, but the validation attributes are in yii\widgets\ActiveForm, so it's likely others would be the same).readonly or disabled attribute to any field and disable AJAX validation for that field, e.g.:<?= $form->field($user, 'name')
->textInput([
'readonly' => 'readonly',
'enableClientValidation' => false,
'enableAjaxValidation' => false,
])
->label(true) ?>
No validation, because the field is readonly AND validation is disabled (normally, even readonly alone should suffice, there should be no focus/blur events for a disabled input, removing which would fix it in this case).
AJAX request for validation still goes through.
The same happens if you replace readonly with disabled.
Also, in my case, the field had no rules defined, since it was taken from another model for display purposes only.
| Q | A
| ---------------- | ---
| Yii version | 2.0.15.1
| PHP version | 7.0.28
| Operating system | Windows 7
| Browser | Google Chrome v67
Why don't you use forums for such questions?
You need to disable validation like this:
<?= $form->field($model, 'number', [
'enableAjaxValidation' => false, // <------------
])->textInput(['readonly' => 'readonly']);
?>
It's not a question, it's a bug. Now go pester someone else.
@jurchiks its ok, dont mind, he might be mistaken.
/*
*@param array $options the tag options in terms of name-value pairs. These will be rendered as
* the attributes of the resulting tag.
*/
textInput($options = [])
Is 'enableClientValidation' a tag attribute?
@samdark This issue should be closed as it is a question more than a bug because the enableClientValidation should be provided as the field() parameter rather than textInput().
Most helpful comment
docs
Is 'enableClientValidation' a tag attribute?