Looking to hire Laravel developers? Try LaraJobs

forms-for-laravel maintained by roundly-consulting

Description
Manage form structures, fields, and submissions in the database.
Last update
2026/10/03 20:40 (dev-main)
License
Downloads
2

Comments
comments powered by Disqus

Forms for Laravel

Define multi-step forms — groups and fields — in your database, validate user input against per-field rules, and store submissions you can read back as typed answers. Everything is driven by Eloquent models you can swap for your own.

Installation

Requires PHP 8.4, Laravel 12 or 13.

composer require roundly-consulting/forms-for-laravel
php artisan vendor:publish --tag="forms-migrations"
php artisan vendor:publish --tag="approvals-migrations" --tag="attributes-migrations" --tag="media-migrations"
php artisan migrate

The migrations are not loaded automatically, and the companion packages' migrations are needed too. If your senders have UUID/ULID keys, set FORMS_KEY_TYPE before migrating.

Usage

Define a form once, with its groups (steps) and fields:

use RoundlyConsulting\Forms\Facades\Forms;
use RoundlyConsulting\Forms\GroupBuilder;

Forms::define('contact', 'Contact us')
    ->public()
    ->group('details', 'Your details', function (GroupBuilder $g): void {
        $g->field('name', 'Name')->rules(['required', 'string']);
        $g->field('email', 'Email')->email()->required();
    })
    ->group('message', 'Message', function (GroupBuilder $g): void {
        $g->field('body', 'Message')->textarea()->required();
    })
    ->create();

Validate and store a submission — input arrives keyed by form.group.field (contact.details.name):

$form = Forms::find('contact');

Forms::validate(form: $form, request: $request);   // throws ValidationException on failure

$result = Forms::submit(form: $form, request: $request, sender: $request->user());
$result->uuid;                                      // the submission's reference id

Read the answers back, one keyed set per submission:

$answers = Forms::submissions($form)->latest()->get();

$answers->first()->values;   // ['name' => 'Jane', 'email' => 'jane@example.com', 'body' => 'Hello!']

Documentation

The full documentation — configuration, every feature and its API, and testing — lives on our website: roundly-consulting.com/open-source/docs/forms-for-laravel

Release notes are in CHANGELOG.md. To contribute, see the contributing guide.

Support our work

This package is free and open source, built and maintained by Roundly Consulting. If it saves you time, please consider supporting our open-source work — a one-time donation, a monthly pledge on Patreon or a crypto donation helps fund maintenance, new features and new packages.

License

The MIT License (MIT). Please see LICENSE for more information.