Code sample
//View code
use buttflatteryormwizard\FormWizard;
echo FormWizard::widget([
'formOptions'=>[
'id'=>'my_form_ajax',
'enableClientValidation'=>false,
'enableAjaxValidation'=>true,
],
'steps' => [
[
'model' => $shootsModel,
'title' => 'My Shoots',
'description' => 'Add your shoots',
'formInfoText' => 'Fill all fields'
],
[
'model' => $shootTagModel,
'title' => 'Shoot Tags',
'description' => 'Add your shoot tags',
'formInfoText' => 'Fill all fields'
],
]
]);
//controller code
public function actionIndex()
{
$shootModel = new \app\models\Shoots();
$shootTagModel = new \app\models\ShootTag();
//for ajax validation
if (Yii::$app->request->isAjax && Yii::$app->request->isPost) {
Yii::$app->response->format = Response::FORMAT_JSON;
$shootModel->load(Yii::$app->request->post());
$shootTagModel->load(Yii::$app->request->post());
return array_merge(ActiveForm::validate($shootModel),ActiveForm::validate($shootTagModel) );
}
return $this->render('index', ['shootsModel' => $shootModel, 'shootTagModel' => $shootTagModel]);
}