laravel-enso/forms is a Laravel package for json-based form builder for laravel enso.
It currently has 123 GitHub stars and 54.170 downloads on Packagist (latest version 9.1.1).
Install it with composer require laravel-enso/forms.
Discover more Laravel packages by laravel-enso
or browse all Laravel packages to compare alternatives.
Last updated
Forms is the JSON-based form builder used across Laravel Enso backends.
The package loads form templates from JSON, builds create and edit payloads around Eloquent models, computes actions and meta configuration, validates template structure, and ships test traits for common create/edit/destroy flows.
It is a backend payload builder, not a standalone UI package. The canonical frontend companion is @enso-ui/forms, which renders the payloads produced by this package.
Install the package:
composer require laravel-enso/forms
Optional publishes:
php artisan vendor:publish --tag=forms-config
php artisan vendor:publish --tag=forms-resources
Form.Create or edit a form payload:
use LaravelEnso\Forms\Services\Form;
$form = new Form(__DIR__.'/Templates/example.json');
$createPayload = $form->create();
$editPayload = $form->edit($model);
The JSON template must include at least:
methodsectionsrouteParamsThe root template may also include:
title, iconactionsauthorizeautosaveclearErrorsControldebouncedividerTitlePlacementlabelsparamsreadonlyroutePrefixroutestabsEach section must define:
columnsfieldsOptional section attributes are:
dividertitlecolumntabslothiddenEach field must define:
labelnamevaluemeta{
"title": "Example",
"icon": "user",
"method": null,
"routePrefix": "administration.users",
"routeParams": {},
"actions": ["store", "update", "destroy", "back"],
"sections": [
{
"columns": 2,
"title": "General",
"fields": [
{
"label": "Name",
"name": "name",
"value": "",
"meta": {
"type": "input",
"content": "text",
"custom": false
}
},
{
"label": "Roles",
"name": "roles",
"value": [],
"meta": {
"type": "select",
"multiple": true,
"source": "administration.roles.options",
"custom": false
}
}
]
}
]
}
Form service APIThe LaravelEnso\Forms\Services\Form object is not just a loader. It is a fluent mutator for the template before create() or edit() finalizes the payload.
Common methods:
create(?Model $model = null)edit(Model $model)actions(...$actions)routePrefix(string $prefix)route(string $action, string $route)routeParams(array $params)title(string $title)icon(string $icon)append(string $param, mixed $value)authorize(bool $authorize)labels(bool $labels)Field and section mutators:
label(string $field, string $value)options(string $field, mixed $value)value(string $field, mixed $value)meta(string $field, string $param, mixed $value)columns(string $section, int $value)hide(...$fields) / show(...$fields)disable(...$fields)readonly(...$fields)readonly() / readonly(bool $readonly)hideSection(...$sections) / showSection(...$sections)hideTab(...$tabs) / showTab(...$tabs)Example:
use LaravelEnso\Forms\Services\Form;
$form = (new Form(app_path('Forms/Templates/users.json')))
->title('Edit User')
->icon('user')
->routePrefix('administration.users')
->append('locale', app()->getLocale())
->label('email', 'Login Email')
->options('role_id', $roles)
->value('is_active', true)
->readonly('email')
->readonly()
->hide('password')
->meta('phone', 'placeholder', '+40 700 000 000');
$payload = $form->edit($user);
The backend validator accepts these meta.type values:
inputselectdatepickertimepickertextareapasswordwysiwygThe frontend companion @enso-ui/forms currently renders these combinations:
input with content: textinput with content: numberinput with content: emailinput with content: passwordinput with content: encryptinput with content: moneyinput with content: checkboxselecttextareadatepickertimepickerwysiwygImportant behavior:
************************ when the model already has a valuereadonly is preserved in the payload so the frontend can render the whole form without mutating actionsmeta.readonly remains available for locking individual fieldssource routes are converted to relative application pathsoptions are expanded through ::select() and default to translated labelswysiwyg fields use TinyMCE by default and receive the configured TinyMCE API key automaticallywysiwyg fields may set editor: trix to use the Trix frontend editor insteadThe validator accepts the following optional meta keys:
options, multiple, custom, contentstep, min, maxdisabled, readonly, hiddensource, format, altFormat, timerows, placeholdertrackBy, labeltooltip, symbol, precision, thousand, decimalpositive, negative, zeroresize, translatedtime12hr, disable-clearobjects, toolbar, plugins, editor, taggablesearchMode, params, pivotParams, customParamsValidator runs four checks:
Structure: verifies root attributes, section format, columns, and tab consistencyActions: only allows Enso form actions supported by the packageRoutes: requires actual named routes for every action except backFields: verifies field attributes, checkbox values, select value shape, and delegates meta validationNotable enforced rules:
back and storeback, create, show, update, and destroyselect fields must define options or sourcecolumns: custom requires an integer column per fieldEnum-backed select fields may opt out of frontend label translation by setting
"translated": false explicitly in the template.
The canonical renderer is @enso-ui/forms.
Its public Vue components are:
EnsoFormVueFormCoreFormThe package integrates with companion UI packages such as:
@enso-ui/select@enso-ui/datepicker@enso-ui/wysiwyg@enso-ui/money@enso-ui/switch@enso-ui/tabsEnsoForm also exposes runtime helpers to the host application, including:
fetch()submit()field(name)param(name)routeParam(name)fill(state)setOriginal()undo()hideField(name) / showField(name)hideTab(name) / showTab(name)LaravelEnso\\Forms\\Services\\FormLaravelEnso\\Forms\\Services\\BuilderLaravelEnso\\Forms\\Services\\Validatorconfig/enso/forms.phpapp/Forms/Builders/ModelForm.phpapp/Forms/Templates/template.phpvalidationsbuttonsaltDateFormatselectPlaceholderauthorizedividerTitlePlacementlabelstinyMCEApiKeyCreateFormEditFormDestroyFormRequired Enso packages:
Companion frontend package:
are welcome. Pull requests are great, but issues are good too.
Thank you to all the people who already contributed to Enso!