Single Model Across Steps
Code sample
To use a single model across steps you can use the except
and only
options intelligently, make sure you are not using both of these options for the same step.
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.
]
]
]
]);