I have a form inside popup. i need validation only at submit , how to process the validation errors from ajax submit .
This is my action
$model = new UserVisit();
if ($model->load(Yii::$app->request->post())) {
if(isset($_POST['date_selected'])){
$model->arrival_date = strtotime($_POST['date_selected']);
$model->departure_time = $model->arrival_date+60*30;
}
if($model->save()){
Yii::$app->response->format = 'json';
$msg = 'Schedule created successfully.';
return [
'status'=>'success',
'message' => $msg,
];
}else {
Yii::$app->response->format = 'json';
return \yii\widgets\ActiveForm::validate($model);
}
}