This is a helper method that simplifies the way of writing AJAX validation code for tabular input.
For example, you may use the following code in a controller action to respond
to an AJAX validation request:
php
... load $models ...
if (Yii::$app->request->isAjax) {
Yii::$app->response->format = Response::FORMAT_JSON;
return ActiveForm::validateMultiple($models);
}
... respond to non-AJAX request ...
public static validateMultiple ( array $models, mixed $attributes = null ) : array | ||
$models | array | an array of models to be validated. |
$attributes | mixed | list of attributes that should be validated. If this parameter is empty, it means any attribute listed in the applicable validation rules should be validated. |
return | array | the error message array indexed by the attribute IDs. |