Forms
Description
Forms renders the backend-driven Enso form contract exposed by laravel-enso/forms.
The package combines:
- a renderless engine that loads the form template, tracks state, computes payloads, and submits data
- Bulma shells that render headers, sections, tabs, actions, and fields
- field components that map backend field metadata to concrete UI controls
Installation
Install the package:
yarn add @enso-ui/forms
Features
- renders full Enso forms from backend JSON templates
- exposes
VueFormandEnsoFormas the main public shells - supports standard field types such as input, select, money, date, time, switch, textarea, and wysiwyg
- supports custom field slots and custom section slots
- supports autosave, tabbed forms, undo, create/show/destroy actions, and redirect flows
- exposes public helpers for filling values, reading dirty state, showing and hiding tabs, and manipulating fields
Usage
Basic usage with VueForm:
<script setup>
import { VueForm } from '@enso-ui/forms/bulma';
</script>
<VueForm
:http="http"
:path="route('administration.users.edit', 1)" />
Enso-aware usage with route and bookmark integration:
<script setup>
import { EnsoForm } from '@enso-ui/forms/bulma';
</script>
<EnsoForm :disable-state="false" />
API
Bulma Exports
Import from @enso-ui/forms/bulma.
Exported components:
VueFormEnsoFormFormFieldFormFieldGroupActionDateFieldInputFieldMoneyFieldSelectFieldSwitchFieldTextareaFieldTimeField
VueForm
Framework-agnostic form shell that wraps CoreForm and renders the standard Bulma form layout.
Responsibilities:
- fetches the backend form contract through
CoreForm - renders the loader skeleton while the contract is loading
- renders
FormContent, default field slots, section slots, and action slots - proxies the public helper methods exposed by
CoreForm
Public methods:
fetch()submit()field(name)param(name)routeParam(name)fill(state)setOriginal()undo()hideTab(tab)showTab(tab)hideField(field)showField(field)
Computed public state:
dataformDatadirtydirtyFieldserrorscustomFieldscustomSections
EnsoForm
Application-aware shell built on top of VueForm.
Additional behavior:
- injects
http,i18n,route,errorHandler,routerErrorHandler, andtoastr - derives
pathfrom the current route when none is passed through attrs - uses Enso UI preferences to resolve the current language
- integrates with bookmarks state persistence when form state tracking is enabled
- shows success toasts after
submitanddestroy
Props:
disableState: boolean = false
Public methods:
- all methods exposed by
VueForm
CoreForm
Renderless engine that owns the backend contract and form lifecycle.
Props:
disableState: boolean = falseerrorHandler: Functionhttp: Functioni18n: Function = key => keylocale: string = 'en'params: object | null = nullpath: stringrouterErrorHandler: FunctionsubmitPath: string | null = nulltemplate: object | null = null
Emits:
createdestroyerrorloadedreadyshowsubmittingsubmitsubmittedtemplate-fetch-errorundo
Provided helpers for descendants:
createcustomFieldscustomSectionsdestroydirtydisableStateerrorCounterrorHandlererrorsfieldBindingsfieldTypefocusErrorhttpi18nlocaleparamssectionCustomFieldssectionsshowstatesubmittabbedtabsundovisibleSection
Public methods:
fetch()submit()field(name)param(name)routeParam(name)fill(data)setOriginal()undo()hideField(fieldName, forceUpdate = true)showField(fieldName, forceUpdate = true)hideSection(section, forceUpdate = true)showSection(section, forceUpdate = true)hideTab(tab)showTab(tab)customFields()customSections()dirty()dirtyFields()errorCount(tab)
Field type mapping:
input + text|number|email|password|encrypt->InputFieldinput + checkbox->SwitchFieldinput + money->MoneyFieldselect->SelectFieldtextarea->TextareaFielddatepicker->DateFieldtimepicker->TimeFieldwysiwyg->WysiwygField
FormField
Single-field wrapper that resolves the field component automatically.
Props:
field: object
Behavior:
- resolves the concrete field component through
fieldType(field) - wires shared props such as
errors,http,i18n, andlocale - renders field labels, tooltips, validation messages, and autosave hooks
FormFieldGroup
Field wrapper with addon and grouped layout support.
Props:
field: objecthasAddons: boolean = falseisGrouped: boolean = false
Slots:
leftright- default
Behavior:
- renders the same automatic field resolution as
FormField - adds left and right slots around the concrete control
- is useful for paired controls such as buttons, prefixes, suffixes, and grouped actions
Action
Reusable button renderer used by FormActions.
Props:
button: objectdisabled: boolean = falseloading: boolean = falsetag: 'a' | 'button'
Emits:
click
Behavior:
- maps known Enso action icon names such as
check,plus,eye,undo, andtrash-alt - renders button label and icon according to the backend action payload
InputField
Standard text, number, email, password, and encrypted input renderer.
Props:
errors: objectfield: objecti18n: Functiontabindex: number | null = null
Emits:
focusblurchanged
Behavior:
- uses numeric
v-model.numberfor numeric content - converts
encryptto a password input - shows
RevealPasswordwhen the field allows reveal mode - clears the field error when the model changes
SelectField
Form wrapper around @enso-ui/select.
Props:
errors: objectfield: objecthttp: Function | null = nulli18n: FunctioncustomParams: object = {}params: object = {}pivotParams: object = {}
Emits:
changed
Public methods:
clear()fetch()
Behavior:
- passes backend metadata straight to
VueSelect - merges field-level params with passed params
- updates
field.meta.optionsafter fetch
DateField
Date and datetime renderer built on top of @enso-ui/datepicker.
Props:
errors: objectfield: objecti18n: Functionlocale: stringtimeOnly: boolean = false
Emits:
changed
Public methods:
clear()
Behavior:
- enables
altInputautomatically whenfield.meta.altFormatexists - reuses the same component for time-only mode through
TimeField
TimeField
Thin wrapper around DateField with timeOnly enabled.
Behavior:
- uses the
DateFieldcontract - renders time-only pickers while preserving the same backend field metadata format
MoneyField
Money input built on top of @enso-ui/money.
Props:
errors: objectfield: objecti18n: Functiontabindex: number | null = null
Emits:
changed
Behavior:
- forwards backend money metadata to the
Moneycomponent - renders
ErrorIconwhen validation fails
SwitchField
Boolean checkbox renderer built on top of @enso-ui/switch.
Props:
errors: objectfield: object
Emits:
changed
Behavior:
- disables itself when the backend field is disabled or readonly
TextareaField
Textarea renderer for multiline fields.
Props:
field: object
Emits:
changed
Behavior:
- reads
errorsandi18nfrom injection - honors
field.meta.resize - clears validation errors on update
Internal Layout Components
These components are not exported from bulma/index.js, but they define the default form layout used by VueForm and EnsoForm:
FormContentorchestrates the header, sections, tabs, and footer actionsFormHeaderrenders the form title and subtitle blockFormSectionlays out rows and columns inside a sectionFormTabsrenders tabbed forms and error counters per tabFormActionsrenders back, destroy, show, create, store, update, error-clear, and undo actionsConfirmationrenders the destroy confirmation inline
Companion Backend Package
Depends On
@enso-ui/datepicker↗@enso-ui/directives↗@enso-ui/divider↗@enso-ui/laravel-validation↗@enso-ui/loader↗@enso-ui/modal↗@enso-ui/money↗@enso-ui/select↗@enso-ui/vue-switch↗@enso-ui/tabs↗@enso-ui/wysiwyg↗
Contributions
are welcome. Pull requests are great, but issues are good too.
Thank you to all the people who already contributed to Enso!