dcodegroup / laravel-form-builder
Simple package which dcode uses to manage form builder
Package info
github.com/DCODE-GROUP/laravel-form-builder
pkg:composer/dcodegroup/laravel-form-builder
Fund package maintenance!
Requires
- php: ^8.2 || ^8.3 || ^8.4 || ^8.5
- laravel/framework: ^11.0||^12.0||^13.0
Requires (Dev)
- larastan/larastan: *
- laravel/pint: ^1.0
- orchestra/testbench: ^9.0
README
Drag-and-drop form builder for Laravel + Vue 3. Define form schemas in an admin UI (FormBuilder), then render and collect submissions with VForm.
| Package | Purpose |
|---|---|
dcodegroup/laravel-form-builder |
Laravel models, migrations, validation helpers |
@dcodegroup-au/form-builder |
Vue components and styles |
Requirements
- PHP 8.2+
- Laravel 11, 12, or 13
Installation
Backend
composer require dcodegroup/laravel-form-builder php artisan form-builder:install php artisan migrate
form-builder:install publishes the create_forms_table and create_form_data_table migrations when they are not already present.
Frontend
npm install @dcodegroup-au/form-builder
Backend quick reference
Backend models & traits
Form
Stores the form definition (title, recipients, status, published_at, fields).
use Dcodegroup\FormBuilder\Models\Form; $form = Form::saveModel([ 'title' => 'Onboarding', 'status' => 'published', 'fields' => $request->input('data.fields'), ]);
FormData
Stores a filled submission (values, completed_at) morph-linked to any model via formable, and related to a Form.
HasFilledForms
Add to any Eloquent model that can have filled forms:
use Dcodegroup\FormBuilder\Models\Traits\HasFilledForms; class Job extends Model { use HasFilledForms; } // Latest (or create) submission for a form $formData = $job->getFormData($form, createNew: true); // Persist values $job->saveFormData($form, $values);
FormValidator
Use on a Form Request to build rules from required fields in the schema:
use Dcodegroup\FormBuilder\Http\Traits\FormValidator; use Illuminate\Foundation\Http\FormRequest; class StoreFormSubmissionRequest extends FormRequest { use FormValidator; public function rules(): array { return $this->getRules([ // extra static rules... ]); } public function messages(): array { return $this->getRules([], isMessage: true); } }
Rules are derived from route('form')?->fields when present, otherwise from request()->input('data.fields').
Database
forms
| Column | Notes |
|---|---|
title |
Form name |
recipients |
JSON (notification emails) |
status |
e.g. draft / published |
published_at |
Set when published |
fields |
JSON schema |
form_data
| Column | Notes |
|---|---|
formable_type / formable_id |
Morph to the owning model |
form_id |
Related forms row |
values |
JSON answers |
completed_at |
Nullable completion timestamp |
Testing
Run package tests (if provided):
composer test
Contributing
Contributions are welcome. Please open issues or pull requests and follow repository conventions.
License
MIT — see LICENSE.md for details.