tranquil-tools / laravel-vue-form-builder
A VueJS/Inertia renderer for tranquil-tools/laravel-form-builder
Package info
github.com/ComfyCodersBV/laravel-vue-form-builder
Language:TypeScript
pkg:composer/tranquil-tools/laravel-vue-form-builder
Requires
- php: ^8.2
- illuminate/console: ^11.0||^12.0||^13.0
- illuminate/support: ^11.0||^12.0||^13.0
- tranquil-tools/laravel-form-builder: ^1.23
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.14
- orchestra/testbench: ^9.0.0||^10.0.0||^11.0.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-arch: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
- dev-main
- 1.27.2
- 1.27.1
- 1.27.0
- 1.26.0
- 1.25.0
- 1.24.0
- 1.23.0
- 1.22.0
- 1.21.1
- 1.21.0
- 1.20.0
- 1.19.0
- 1.18.0
- 1.17.0
- 1.16.1
- 1.16.0
- 1.15.0
- 1.14.0
- 1.13.6
- 1.13.5
- 1.13.4
- 1.13.2
- 1.13.1
- 1.13.0
- 1.12.3
- 1.12.2
- 1.12.1
- 1.12.0
- 1.11.0
- 1.10.2
- 1.10.1
- 1.10.0
- 1.9.0
- 1.8.0
- 1.7.0
- 1.6.0
- 1.5.0
- 1.4.0
- 1.3.4
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.25
- 1.0.24
- 1.0.23
- 1.0.22
- 1.0.21
- 1.0.20
- 1.0.19
- 1.0.18
- 1.0.17
- 1.0.16
- 1.0.15
- 1.0.14
- 1.0.13
- 1.0.12
- 1.0.11
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
This package is auto-updated.
Last update: 2026-11-17 10:23:57 UTC
README
Define Laravel-VueJS forms configurations in PHP.
Documentation
Full documentation is available at docs.comfycoders.nl.
Topics covered:
- Installation
- Creating a Form
- All Field Types, including Display for read-only, computed values
- Vue Usage
- Validation
- Steps (multi-step forms)
- Date & Time, including the touch picker and
TouchTimePicker - Configuration
Required fields
The label of every field whose rules contain required gets an asterisk, with a hidden "(required)" for screen
readers. It is on by default; switch it off app-wide with 'required_indicator' => false in
config/form-builder.php, and override a single field with ->markRequired() or ->markRequired(false). See
Common options.
Field ids and reserved names
Field ids carry the form id: email in a form with ->id('login') renders id="login-email", so two forms with the
same field on one page keep their labels apart. Field names that Inertia's useForm() uses itself (data, errors,
reset, query, transform, ...) are refused when the form is serialized. See
Vue Usage.
Conditions that validate
->if('action', 'rebook') shows a field only while action is rebook, adds exclude_unless:action,rebook to its
rules and leaves it out of the payload while it is hidden, in sections, steps and repeater rows too. A submit button
takes ->labelExpression() and ->disabledIf() to follow the form, such as `Rebook (${ids.length})`, and
$processing tells an expression that the form is submitting. A validation error of a hidden field is shown at the
top of the form after the field label. See
Conditional visibility and
Buttons.
Two forms with the same fields
$form->errorBag('newsletter') keeps the validation errors of a form in their own bag, on the server and in
$page.props.errors, so the errors of two forms with the same field names on one page stay apart. See
Two forms with the same fields.
Your own input, the package's label
An #input-{name} slot on <Form> replaces only the control of a field, and #input-{type} that of every field of a
type. The label, required asterisk, help text, error
and ids stay the package's, and the slot gets id, describedby, modelValue, update, invalid, disabled,
field and form, also inside sections, steps and repeater rows. See
Replacing only the input.
CrudBuilder
Want a complete CRUD solution? Our CrudBuilder builds on top of this FormBuilder and the TableBuilder to give you full create, read, update, and delete flows without repetitive boilerplate.
- Docs: docs.comfycoders.nl/laravel-vue-crud-builder
- GitHub: github.com/ComfyCodersBV/laravel-vue-crud-builder
Installing the CrudBuilder pulls in this package automatically as a Composer dependency.
Quick start
Installation
You can install the package via composer:
composer require tranquil-tools/laravel-vue-form-builder
This is the Vue renderer; it depends on tranquil-tools/laravel-form-builder, the PHP core that
defines the fields, validation and schema. One require pulls in both.
Install the frontend dependencies. The package ships raw .vue files that your application compiles,
so their imports resolve against your node_modules. Beyond what the Laravel Vue starter kit already
gives you:
npm install reka-ui @lucide/vue
A WYSIWYG editor is opt-in. The package imports no editor, so nothing is needed here unless you register one.
Optional: you may publish the config file with:
php artisan vendor:publish --tag="form-builder-config"
This creates config/form-builder.php, which ships with the PHP core.
Alter you vite.config.ts to add an @form-builder alias:
import {defineConfig} from 'vite'; import path from 'path'; export default defineConfig({ plugins: [ // ... ], resolve: { alias: { // Add this: '@form-builder': path.resolve(__dirname, 'vendor/tranquil-tools/laravel-vue-form-builder/resources/js'), }, }, });
Basic usage
<?php declare(strict_types=1); namespace App\Http\Controllers; use App\Forms\CategoryForm; use App\Http\Requests\CategoryFormRequest; use App\Models\ExampleModel; use Inertia\Inertia; use Inertia\Response; class ExampleController extends Controller { public function edit(ExampleModel $model): Response { return Inertia::render('PathToVueFile', [ 'form' => ExampleForm::make() ->action(route('categories.update', $model)) ->method('PUT') ->fill($model), ]); } }
<?php declare(strict_types=1); namespace App\Forms; use App\Models\Template; use TranquilTools\FormBuilder\AbstractForm; use TranquilTools\FormBuilder\Fields\Number; use TranquilTools\FormBuilder\Fields\Select; use TranquilTools\FormBuilder\Fields\Submit; use TranquilTools\FormBuilder\Fields\Text; use TranquilTools\FormBuilder\Fields\Wysiwyg; use TranquilTools\FormBuilder\FormConfig; class ExampleForm extends AbstractForm { public function configure(FormConfig $form) { $form->class(['space-y-4', 'mx-auto', 'mt-3']); } public function fields(): array { return [ Number::make('position') ->label(__('Order')) ->rules([ 'required', 'integer', 'min:1', ]), Text::make('title') ->label(__('Name')) ->autocomplete(false) ->rules([ 'required', 'string', 'max:255', ]), Text::make('description') ->label(__('Description')) ->autocomplete(false) ->rules([ 'required', 'string', 'max:255', ]), Wysiwyg::make('content') ->label(__('Content')), Select::make('template_id') ->label(__('Template')) ->options(Template::all()->pluck('name', 'id')->toArray()) ->rules([ 'nullable', 'exists:templates,id', ]), Submit::make() ->label(__('Save')), ]; } }
<?php declare(strict_types=1); namespace App\Http\Requests; use App\Forms\ExampleForm; use Illuminate\Foundation\Http\FormRequest; class ExampleFormRequest extends FormRequest { public function rules(): array { return ExampleForm::rules(); } }
A field takes classes in two places: ->wrapperClass() (or the older ->class()) replaces the classes of the wrapper
around label, control and errors, and ->inputClass() adds classes to the input, select, checkbox or button itself.
See Common options.
<script setup lang="ts"> import Form from '@form-builder/components/Form.vue'; import {FormSchema} from '@form-builder/types/form-builder'; defineProps<{ form: FormSchema; }>(); </script> <template> <div class="..."> <div class="..."> <Form :schema="form"/> </div> </div> </template>
Click and other event handlers are attached in Vue, never from PHP (->attributes(['@click' => ...]) throws). Pass
them through fieldOverrides, and they land on the button or input itself:
<Form :schema="form" :field-overrides="{ preview: { onClick: () => (previewOpen = true) } }" />
A Button with ->emit('preview') in the form class fires @button on <Form> instead, so the wiring stays visible
in PHP:
<Form :schema="form" @button="(event) => event === 'preview' && (previewOpen = true)" />