Ошибку добавляю через $model->addError('link','Custom error');
Может кто знает в чем проблема?
Код: Выделить всё
public function actionTest() {
$model = new Model(); // extends Model
if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
$model->addError('link','Custom error');
return ActiveForm::validate($model);
}
return ActiveForm::validate($model);
}
Код: Выделить всё
public function rules()
{
return [
[['link'], 'required'],
[['link'], 'string'],
];
}