lekoala / silverstripe-multi-step-form
Multi step forms for SilverStripe
Installs: 8
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 4
Forks: 0
Open Issues: 1
Type:silverstripe-vendormodule
Requires
- php: ^7.4 || ^8
- silverstripe/framework: ^4.4 || ^5
Requires (Dev)
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3.5
This package is auto-updated.
Last update: 2024-12-03 12:54:28 UTC
README
Intro
A simple alternative to multiform
This module does not require storage in the back end and provide a somewhat easier DX.
How it works
Each step of your form should be named the same.
- MyFormStep1
- MyFormStep2
- ...
They should all extends the base MultiStepForm
class and implements the following abstract methods:
- buildFields : returns a field list
- getStepTitle : get the step title
class MyFormStep1 extends MultiStepForm { public static function getStepTitle() { return 'My Step'; } public function buildFields() { $fields = new FieldList(); return $fields; } }
In your controller, you declare a form like this:
private static $allowed_actions = array( 'MyForm' ); public function MyForm() { $class = MyFormStep1::classForCurrentStep($this); return new $class($this); }
Template helpers
You can display the steps using
$MyForm.DisplaySteps
This relies on some default styles that are added by default. You can disable styles and edit custom classes with:
LeKoala\MultiStepForm\MultiStepForm: include_css: true class_active: "current bg-primary text-white" class_inactive: "link" class_completed: "msf-completed bg-primary text-white" class_not_completed: "msf-not-completed bg-light text-muted"
TODO
- Doc
- Tests
Compatibility
Tested with 4.6 but should work on any ^4.4 projects
Maintainer
LeKoala - thomas@lekoala.be