-
Notifications
You must be signed in to change notification settings - Fork 13
Skip Step Validation
On many occasions we have a scenario where we have a related table attached to our main table where we can skip adding a related record or choose to add, for example user registration will involve the account details and profile but there can be an entity like Business Profile OR Books interested in with a hasMany
relation but it isnt necessary that you add the Books or Business Profile, but if you do enter them you will have to go through the validation that depends on the validation rules in that model.
Previously yii2-formwizard
extension would require the validation and wont let you go through the step if the model has any of the fields required, and failed in the above described situation.
With the introduction of the the new option isSkippable
under the steps
configuration then the widget will automatically detect if the user want to skip the whole step or not. It detects if there is any input that has any text or option selected then it wont by pass the step and will require you to enter the required fields for that step depending on the model rules and if you havent added any text in any of the inputs in that step then the widget would interpret that you want to skip the validation for the whole step, and it would let you navigate to the next step.
You just need to provide option as simple boolean true
or false
and the rest is done by the widget. You can use the option like below
use buttflattery\formwizard\FormWizard;
echo FormWizard::widget([
'steps'=>[
[
'model'=>$userModel,
'title'=>'User Info',
'description'=>'Add you account details',
'formInfoText'=>'Fill all fields'
],
[
'model'=> $businessProfile,
'isSkipable'=>true
'title'=>'My Business Profile.',
'description'=>'Add your business profile details.',
'formInfoText'=>'Fill all fields'
],
]
]);
- 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)