There are many suggestions to begin the controller code with this:
if (Yii::$app->request->isAjax && $model->load(Yii::$app->request-
>post()))
{
Yii::$app->response->format = Response::FORMAT_JSON;
return ActiveForm::validate($model);
}
I have tried a few standard methods following validation such as this without success:
if($model->save()){
return $this->redirect(['index']);
}
}
return $this->renderAjax('create', [
'model' => $model,
]);
My question is what code can be placed under the call to 'return ActiveForm::validate($model)' to successfully execute $model->save upon successful validation ?