I have the below code:
[‘state’, ‘required’, ‘when’ => function ($model) {
return $model->country == 'USA';
}, 'whenClient' => "function (attribute, value) {
return $('#country').val() == 'USA';
}"]
The state is required when the country field has a value = ‘USA’
but…
I have a tabular form and.Then…
a need validate the [0]state when field [0]country has a value = ‘USA’
a need validate the [1]state when field [1]country has a value = ‘USA’
a need validate the [2]state when field [2]country has a value = ‘USA’
This topic is on yii doc on de the below link:
http://www.yiiframework.com/doc-2.0/guide-input-validation.html