-
Notifications
You must be signed in to change notification settings - Fork 13
Edit Mode
If you are using the formwizard for editing your data you will feel uneasy as the information is already filled in and you have to navigate through each and every step to change any information in the last step because the anchor links are not clickable keeping in mind the insertion mode where we need to validate the required step fields before moving on to the next, which isnt the case when editing as the information is already validated and saved and we should be able to jump to any step to change any info and the new data would be validated right away. so we can use the option editMode
which takes a simple boolean and the rest is done by the widget. When the option is true
the anchor links are activated and you can click the anchor/ step title to jump to the step.
If you have edit mode enabled and all steps all empty, if you jump to last step and try to submit the form clicking Finish button, it will highlight all steps that have errors and navigate you to the first error step.
If you use the formWizard for adding and editing a simple way would be to pass a var which holds true in actionUpdate()
and false in actionCreate()
and pass to the view.
public function actionUpdate($id)
{
$model = $this->findModel($id);
return $this->render('update', ['editMode' => true, 'model' => $model]);
}
View
echo FormWizard::widget([
'wizardContainerId' => 'my-id',
'editMode' => $editMode,
]);
You can see a demo here
- Get Running with Minimal Options
- Disable ActiveForm Validation
- Enable Ajax Validation
- Add Custom Buttons
- Widget Constants
- Customizing Form Fields
- Configuring File Uploads
- Custom Field Order
- Single Model Across Steps
- Multiple models in a single step
-
Tabular Steps-(New)
- Working With Widgets
- Limiting Rows
- Dependent Inputs Since v1.7.2
- Skip-able Step-(Since v1.5.0)
- Enable Preview Step-(New)
- Group Fields-(New)
- Enable Form Persistence-(New)
- Enable Edit Mode - (Since v1.6.4)