Vue Form Package
Can be used outside of the Enso ecosystem.
For live examples and demos, you may visit laravel-enso.com
Should be used with its backend sibling
# InstallationInstall the package:
(within Enso, remember to cd
into the client
folder before installing front-end assets)
Note that this package has a couple of external dependencies. Read here for more info.
# Exports@enso-ui/forms/bulma
:
VueForm
,EnsoForm
,FormField
,Action
,DateField
,InputField
,MoneyField
,SelectField
,SwitchField
,TextareaField
,TimeField
,@enso-ui/forms/renderless
:
CoreForm
,Import the desired forms(s):
# CoreFormRenderless component.
# Propspath
- string
, required - the URI for the form data/template, in which case the template
parameter is no longer requiredtemplate
- object
, required - the form template object, which may be passed directly, in which case the path
parameter is no longer requireddisableState
- boolean
, optional, default false
- if true, then the form state monitoring functionality is disabled (and for example, you won't know when the form is dirty)errorHandler
- function
, optional - an error handling function for the axios requestsi18n
- Function
, optional - the function that performs translationslocale
- string
, optional, default en
- used for the date fieldsparams
- object
, optional - parameters that get sent to the backend when fetching the form dataThe components has several methods, of which the following are most useful, making sense to have them available in the CoreForm's concrete implementations:
fetch()
, fetches the form data & template from the back-endcustomFields()
, returns an array of custom fieldscustomSections()
, returns an array of custom sectionstabs()
, returns an array of tabssectionFields(section)
, returns an array of non hidden fields for the given sectionsectionCustomFields(section)
, returns an array of non hidden custom fields for the given sectionsections(tab)
, returns an array of sections for the given tabfield(field)
, returns the field with the given nameparam(field)
, returns the parameter with the given namerouteParam(field)
, returns the route parameter with the given namefill(data)
, performs a 'fill' for the field names/values given in the data parametersetOriginal()
, updates the 'original' data store with the current form data statehideTab(tab)
, sets the given tab as hiddenshowTab(tab)
, sets the given tab as visiblehideField(fieldName)
, sets the given field as hiddenshowField(fieldName)
, sets the given field as visibleThe following event are emitted:
ready
, on form init and after form fetch. The payload is the entire componentloaded
, after fetching the form. The payload is the response data.show
, when clicking the show button. There is no payload.create
, when clicking the create button. There is no payload.submit
, after performing a submit. The payload is the response data.error
, after a submit error. The payload is the response error.destroy
, after performing a destroy. There is no payload.undo
, after performing an undo. There is no payload.The bulma styled form component built on top of the renderless version of the component.
# Example: # MethodsThe following methods are cascaded from the renderless CoreForm component:
fetch()
, fetches the form data & template from the back-endsubmit()
, submits the formfield(field)
, returns the field with the given nameparam(field)
, returns the parameter with the given namerouteParam(field)
, returns the route parameter with the given namefill(data)
, performs a 'fill' for the field names/values given in the data parametersetOriginal()
, updates the 'original' data store with the current form data statehideTab(tab)
, sets the given tab as hiddenshowTab(tab)
, sets the given tab as visibleprops
object that has to be bound to the custom field, besides your custom logic.actions-left
and actions-right
slots to place controls in the form's actions areaDesigned to be used within the Enso ecosystem, requiring less configuration from the dev.
# MethodsThe following methods are cascaded from the renderless CoreForm component, through the VueForm component and available here:
fetch()
, fetches the form data & template from the back-endsubmit()
, submits the formfield(field)
, returns the field with the given nameparam(field)
, returns the parameter with the given namerouteParam(field)
, returns the route parameter with the given namefill(data)
, performs a 'fill' for the field names/values given in the data parametersetOriginal()
, updates the 'original' data store with the current form data statehideTab(tab)
, sets the given tab as hiddenshowTab(tab)
, sets the given tab as visiblehideField(fieldName)
, sets the given field as hiddenshowField(fieldName)
, sets the given field as visibleSome forms require display-dependencies between one or more field and others. Example scenario : an entity model could have or not an address, therefore there is a checkbox field inside the form called "Has Address" that will show or hide some form fields related to address details.
# Vue Template # PropsAll the props from the renderless component can be provided here
# Components for custom fieldsStarting with v1.1.0 you should always use FormField
when dealing with slots.
If you want further customization the package provides a component for each type of field:
# DateField # InputField # MoneyField # SelectField # SwitchField # TextareaField.vue # TimeField.vue # WysiwygField.vueDon't forget to add your own label when when using the dedicated component.
# Example: # DateFieldThe component takes the following required properties:
errors
, the form's errors objectfield
, the form's field object, for this date fieldi18n
, the form's translation function, for this date fieldlocale
, the locale string to be used for the datepicker used under the hoodtimeOnly
, the boolean flag that indicates that the component should only display timeThe component takes the following required properties:
errors
, the form's errors objectfield
, the form's field object, for this input fieldi18n
, the form's translation function, for this date fieldThe component takes the following required properties:
errors
, the form's errors objectfield
, the form's field object, for this money fieldi18n
, the form's translation function, for this date fieldThe component takes the following required properties:
errors
, the form's errors objectfield
, the form's field object, for this select fieldi18n
, the form's translation function, for select date fieldcustomParams
, the custom params object passed to the VueSelect used under the hoodparams
, the params object passed to the VueSelect used under the hoodpivotParams
, the pivot params object passed to the VueSelect used under the hoodThe component takes the following required properties:
errors
, the form's errors objectfield
, the form's field object, for this switch fieldThe component takes the following required properties:
field
, the form's field object, for this textarea fieldThe component takes the properties as the DateField
component above.
The component takes the following required properties:
field
, the form's field object, for this visual editor fieldFor questions and support please use the issues functionality for this package's github repository.
Please make sure to search for existing issues before creating a new issue, and when opening a new issue, fill the required information in the issue template.
Issues not conforming to the guidelines may be closed immediately.
# Contributionsare welcome. Pull requests are great, but issues are good too.
Thank you to all the people who already contributed to Enso!
# LicenseRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4