Download the PHP package bayareawebpro/laravel-multistep-forms without Composer
On this page you can find all versions of the php package bayareawebpro/laravel-multistep-forms. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bayareawebpro/laravel-multistep-forms
More information about bayareawebpro/laravel-multistep-forms
Files in bayareawebpro/laravel-multistep-forms
Package laravel-multistep-forms
Short Description Responsable MultiStep Form Builder for Laravel.
License MIT
Informations about the package laravel-multistep-forms
Laravel MultiStep Forms
https://packagist.org/packages/bayareawebpro/laravel-multistep-forms
Multistep Form Builder is a "responsable" class that can be returned from controllers.
- Specify a view to use Blade or go headless with JSON for use with Javascript frameworks.
- Configure the rules, messages and supporting data for each step with simple arrays.
- Submit to the same route multiple times to merge each validated request into a namespaced session key.
- Hook into each step before or after validation to interact with the form or return a response.
Installation
Example Usage
Make New Instance
Make a new instance of the builder class with optional view and data array. You
should always set the namespace
for the form session to avoid conflicts with
other parts of your application that use the session store.
GET
requests will load the form state and data for the saved current step or fallback to step 1.POST
,PUT
,PATCH
etc... will validate and process the request for any step and proceed to the next configured step.DELETE
will reset the session state and redirect back (blade), or return aJsonResponse
.- Backwards navigation (via get param) can be enabled via the
canNavigateBack
method.
Configure Steps
Define the rules, messages and data for the step. Data will be merged
with any view data defined in the make
method and be included in the JsonResponse
.
** Use a Closure
to lazy load data per-key.
Use an array:
Or use an invokable class (recommended)
BeforeStep / OnStep Hooks
Define a callback to fired before a step has been validated. Step Number or * for all.
- Use a step integer, or asterisk (*) for all steps.
- You can return a response from these hooks.
Handle UploadedFiles
Specify a callback used to transform UploadedFiles into paths.
Reset / Clear Form
- Ajax: Submit a DELETE request to the form route.
- Blade: Use an additional submit button that passes a boolean (truthy) value.
JSON Response Schema
The response returned will have two properties:
Public Helper Methods
stepConfig
Get the current step configuration (default), or pass an integer for a specific step:
getValue
Get a field value (session / old input) or fallback:
setValue
Set a field value and store in the session:
save
Merge and save key/values array directly to the session (does not fire beforeSaveCallback
):
reset
Reset the form state to defaults passing an optional array of data to seed.
withData
Add additional non-form data to all views and responses:
currentStep
Get the current saved step number:
requestedStep
Get the incoming client-requested step number:
isStep
Is the current step the provided step:
prevStepUrl
Get the previous step url.
lastStep
Get the last step number:
isLastStep
Is the current step the last step:
isPast,isActive,isFuture
Blade Example
Data will be injected into the view as well as the form itself allowing you to access the form values and other helper methods.
Vue Example
Form state and data will be returned as JSON when no view is specified or the request prefers JSON. You can combine both techniques to use Vue within blade as well.
Example Form Component
Example Input Component
Example Select Component
All versions of laravel-multistep-forms with dependencies
illuminate/http Version ^11.0
illuminate/support Version ^11.0
illuminate/session Version ^11.0
illuminate/contracts Version ^11.0
illuminate/validation Version ^11.0