anthonyedmonds / laravel-form-builder
Create one-thing-per-page forms with forking logic and task lists; ideal for the GOV.UK Design System!
dev-main
2024-04-29 13:04 UTC
Requires
- php: ^8.3
- illuminate/support: ^11
Requires (Dev)
This package is auto-updated.
Last update: 2024-04-29 13:43:26 UTC
README
Create one-thing-per-page forms with forking logic and task lists; ideal for the GOV.UK Design System!
What's in the box?
- Laravel 11 compatible classes for generating dynamic forms
- A complete start-to-finish form lifecycle
- Tasks to group questions into manageable chunks
- Forks to allow branching questions
- Session and database persisted models
- Support for looping, skipping, and drafting answers
Installation
-
Install the library using Composer:
composer require anthonyedmonds\laravel-form-builder
- Laravel will automatically detect and register the Laravel Form Builder service provider.
-
Publish the config file:
php artisan vendor:publish --provider="AnthonyEdmonds\LaravelFormBuilder\ServiceProviders\LaravelFormBuilderServiceProvider"
-
Add the form routes to your
web.php
routes file:Route::laravelFormBuilder();
-
Create and configure a
Form
class, filling it with any number ofTask
,Fork
, andQuestion
classes. -
Create a
Model
with theHasForm
trait -
Access the form and away you go!
// Starting fresh... return MyModel::form()->start(); // RedirectResponse // From existing... return $myModel->form()->start(); // RedirectResponse
<!-- From blade... --> <a href="{{ $myModel->form()->startRoute() }}">Start form</a>
Documentation
Start
Task
Fork
Question
Summary
Finish
Contribution
Feel free to submit ideas and features as issues, and raise pull requests.