Stepped Form submitter for Laravel & Lumen.
lexal/laravel-stepped-form-submitter is a Laravel package for stepped form submitter for laravel & lumen..
It currently has 1 GitHub stars and 456 downloads on Packagist (latest version v4.0.0).
Install it with composer require lexal/laravel-stepped-form-submitter.
Discover more Laravel packages by lexal
or browse all Laravel packages to compare alternatives.
Last updated
The package is based on the Form Submitter and built for the Laravel framework.
Table of Contents
PHP: >=8.2
Laravel: ^11.0 || ^12.0
Via Composer
composer require lexal/laravel-stepped-form-submitter
Run the following command to publish the package config file:
php artisan vendor:publish --provider="Lexal\LaravelSteppedFormSubmitter\ServiceProvider\ServiceProvider"
The configuration file config/form-submitter.php has the following options:
transaction_class - place a class name, instance or service alias which the FormSubmitter will use to handle
transactions. Place null or remove config to disable transactions.
'transaction_class' => DatabaseTransaction::class,
submitters - specify at least one form submitter that the stepped form will use to submit entity on FormFinished
event. Must implement FormSubmitterInterface.
'submitters' => [
// list of form submitters
],
Add form transaction implementation, if necessary.
use Lexal\FormSubmitter\Transaction\TransactionInterface;
final class DatabaseTransaction implements TransactionInterface
{
public function start(): void
{
// start transaction
}
public function commit(): void
{
// commit transaction
}
public function rollback(): void
{
// rollback transaction
}
}
Create custom form submitters.
use Lexal\FormSubmitter\FormSubmitterInterface;
final class CustomerFormSubmitter implements FormSubmitterInterface
{
public function supportsSubmitting(mixed $entity): bool
{
return $entity instanceof Customer;
}
public function submit(mixed $entity): mixed
{
// save entity to the database
return $entity;
}
}
Update configuration file. Add form submitters and transaction class (if necessary).
return [
'transaction_class' => DatabaseTransaction::class,
'submitters' => [
CustomerFormSubmitter::class,
],
];
Form submitter will call your custom form submitter automatically if it supports submitting of stepped-form entity.
Laravel Stepped Form Submitter is licensed under the MIT License. See LICENSE for the full license text.