DEMOS

Code Sample

use buttflattery\formwizard\FormWizard;
echo FormWizard::widget([
    'steps'=>[
        [
            'model'=>$shootsModel,
            'title'=>'My Shoots',
            'description'=>'Add your shoots',
            'formInfoText'=>'Fill all fields'
        ],
        [
            'model'=> $shootTagModel,
            'title'=>'My Shoots',
            'description'=>'Add your shoots',
            'formInfoText'=>'Fill all fields'
        ],
    ]
]);
Fill all fields
Fill all fields

Code Sample

use buttflattery\formwizard\FormWizard;
echo FormWizard::widget([
    'steps' => [
        [
            'model' => $shootsModel,
            'title' => 'Shoot Description',
            'description' => 'Provide description only',
            'formInfoText' => 'The date fields(created_at, updated_at), and shoot_type, are disabled for this step by using the `disabled` option.',
            'fieldConfig' => [
                'except' => ['created_at', 'updated_at', 'shoot_type'], // all fields except these will be added in the step
            ]
        ],
        [
            'model' => $shootsModel,
            'title' => 'Shoot Dates',
            'description' => 'Provide dates only',
            'formInfoText' => 'Provide Shoot Dates',
            'fieldConfig' => [
                'only' => ['created_at', 'updated_at', 'shoot_type'], // only these field will be added in the step, rest all will be hidden/ignored.
            ]
        ]
    ]
]);

To use a single model across steps you can use the disabled and only options intelligently, make sure you are not using both of these options for the same step.

info_outline
The date fields(created_at, updated_at), and shoot_type, are disabled for this step by using the `disabled` option.

Provide Shoot Dates
 

Code Sample

use buttflattery\formwizard\FormWizard;
echo FormWizard::widget([
'formOptions' => [
    'id' => 'my_form_multi_model_single_step',
    'options'=>[
        'class'=>'form-inline'
    ],
],
'steps' => [
    [
        'model' => [$shootsModel,$shootTagModel],
        'title' => 'My Shoots',
        'description' => 'Add your shoots',
        'formInfoText' => 'Fill all fields',
    ],
    [
        'model' => $userModel,
        'title' => 'Shoot Tags',
        'description' => 'Add your shoot tags',
        'formInfoText' => 'Fill all fields',
    ],
],

]);

To use a multiple model across steps you can pass the array of models to the model option.

Fill all fields
Fill all fields

Code sample

use buttflatteryormwizard\FormWizard;
echo FormWizard::widget([
    'formOptions'=>[
        'id'=>'my_form',
        'enableClientValidation'=>false,
    ],
    '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'
        ],
    ]
]);
Fill all fields
Fill all fields

Code sample

//View code
use buttflatteryormwizard\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]);
}
Fill all fields
Fill all fields

Code sample

//View code
use buttflatteryormwizard\FormWizard;
$js = <<< JS
    var mybutton = $( '<button id="new"></button>' ).text( 'New Button' )
    .addClass( 'btn btn-warning' ).on("click",function(e){
        e.preventDefault();
        alert("hello");
    });
\JS;
$this->registerJs($js, yii\web\View::POS_READY);

echo FormWizard::widget([
    'toolbarExtraButtons' => new \yii\web\JsExpression('[mybutton]'),
    'steps' => [
        [
            'model' => $shootsModel,
            'title' => 'My Shoots',
            'description' => 'Add your shoots',
            'formInfoText' => 'Fill all fields'
        ],
        [
            'model' => $shootTagModel,
            'title' => 'Shoot Tags',
            'description' => 'Add your shoots',
            'formInfoText' => 'Fill all fields'
        ],
    ]
]);
Fill all fields
Fill all fields

Code sample

//View code
use buttflatteryormwizard\FormWizard;

echo FormWizard::widget([
    'theme' => FormWizard::THEME_ARROWS,
    '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'
        ],
    ]
]);
Fill all fields
Fill all fields

Code sample

//View code
use buttflatteryormwizard\FormWizard;

echo FormWizard::widget([
    'theme' => FormWizard::THEME_CIRCLES,
    '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'
        ],
    ]
]);
Fill all fields
Fill all fields

Code sample

//View code
use buttflatteryormwizard\FormWizard;

echo FormWizard::widget([
    'theme' => FormWizard::THEME_DOTS,
    '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'
        ],
    ]
]);
Fill all fields
Fill all fields

Code sample

//View code
use buttflatteryormwizard\FormWizard;

echo FormWizard::widget([
    'theme' => FormWizard::THEME_MATERIAL,
    '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'
        ],
    ]
]);
Fill all fields
Fill all fields

Code sample

//View code
use buttflatteryormwizard\FormWizard;

echo FormWizard::widget([
    'theme' => FormWizard::THEME_MATERIAL_V,
    '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'
        ],
    ]
]);
Fill all fields
Fill all fields