Laraform
Main Laraform\Laraform instance.
#Properties
| Name | Type | Default | Description |
|---|---|---|---|
| schema | object |
- | List of elements to be rendered. |
| component | string |
'laraform' |
Vue component to render. |
| storePath | string |
- | Vuex store (state) path. |
| model | string |
- | Name of model class. |
| primaryKey | string |
'id' |
Name of primary key. |
| theme | string |
config.theme |
Theme for the form. |
| columns | array|number |
- | Column sizes definition. |
| class | string |
- | CSS class of form. |
| classes | array |
- | Theme classes override. |
| labels | boolean |
config.labels |
Whether label should render for elements without label defined. |
| formErrors | boolean |
config.formErrors |
Whether form errors should be displayed above the form. |
| enableStepsOnLoad | boolean |
config.enableStepsOnLoad |
Whether steps should be enabled when loading data. |
| completeStepsOnLoad | boolean |
config.completeStepsOnLoad |
Whether steps should be enabled & completed when loading data. |
| layout | string |
- | Form layout. |
| buttons | array |
- | Form buttons. |
| tabs | array |
- | Tabs descriptor. |
| wizard | array |
- | Wizard descriptor. |
| wizardControls | boolean |
true |
Whether wizard controls should appear when using wizard. |
| with | array |
- | Additional "data" props to set for the form. |
| messages | array |
- | Custom validation messages. |
| multilingual | boolean |
false |
Whether or not the form is multilingual. |
| locale | string |
config.locale |
Locale of the form. |
| language | string |
config.language |
Default language of form when multilingual. |
| languages | array |
config.languages |
Array of languages to use. |
| endpoint | string |
config.endpoint |
Endpoint to where the form will be submitted. |
| method | string |
config.method |
Method how the form should be submitted. |
| timezone | string |
config.timezone |
Timezone of the app. |
| userTimezone | string |
config.userTimezone |
Fixed timezone of the user. |
| validateOn | string |
config.validateOn |
Validated form on these events. |
| key | integer|string |
- | Key of current entity. |
| invalid | boolean |
false |
Determine if form is invalid. |
| validated | boolean |
false |
Determine if form has been validated. |
| data | array |
[] |
Form data. |
| updates | updates |
[] |
Contains any data that has been generated during processing data, like new IDs. Can be used to forward to the frontend to update values. |
#Methods
# validate() @returns {void} @public
Validates form.
# load() @returns {Laraform} @public
Parameters
dataarray|integer : data or entity ID to be loaded.
Loads data to form.
# save() @returns {void} @public
Saves data.
# render() @returns {string} @public
Renders form DOM element.
# with() @returns {Laraform} @public
Sets the 'with' property.
# on($event, $callback) @returns {void} @public
Parameters
eventstring : event to subscribe.callbackcallback : callback to call when the event is fired.
Subscribes to event.
# fail($message, $payload = []) @returns {array} @public
Parameters
messagestring : response message.payloadarray : response payload (optional).
Creates a fail response.
# success($message = null, $payload = []) @returns {array} @public
Parameters
messagestring : response message (optional).payloadarray : response payload (optional).
Creates a success response.
# schema() @returns {array} @public
Returns the schema of element definitions.
# buttons() @returns {array} @public
Returns on array of button definitions.
# wizard() @returns {array} @public
Returns wizard schema definition.
# tabs() @returns {array} @public
Returns tabs schema definition.
# messages() @returns {array} @public
Returns custom validation message definitions.
# setData($data) @returns {void} @public
Parameters
dataarray : data to set.
Sets form data.
# setKey($key) @returns {void} @public
Parameters
keyinteger|string : entity key to be set.
Sets entity's key.
# getKey() @returns {integer|string} @public
Returns entity's key.
# hasKey() @returns {boolean} @public
Determines if entity's key is set.
# getEntity() @returns {Illuminate\Database\Eloquent\Model} @public
Returns entity based on current key. Works only if the element list contains a key field for primary key.
# database->getEntity() @returns {Illuminate\Database\Eloquent\Model} @public
Returns the last touched entity from database (when using save).
# hasModel() @returns {boolean} @public
Determines if model is set.
# getValidator() @returns {Laraform\Validation\Validator} @public
Returns the underlying validator instance.
# isInvalid() @returns {boolean} @public
Determines if form is invalid.
# isValidated() @returns {boolean} @public
Determines if form is validated.
# getErrors() @returns {array} @public
Returns form errors.
# setKeyFromData() @returns {void} @public
Sets entity key from current form data.
# addToUpdates($updates) @returns {void} @public
Parameters
updatesarray : data to add to updates.
Merges data to current updates.
# getUpdates() @returns {array} @public
Returns form udpates.
# setElements() @returns {void} @public
Recreates form elements based on schema. Need to be used when changing initial schema.
# setMethod($method) @returns {Laraform} @public
Parameters
methodarray : method type. Possible values:GET,POST,PUT,PATCH,DELETE.
Sets form method.
# setEndpoint($endpoint) @returns {Laraform} @public
Parameters
endpointarray : endpoint.
Sets endpoint where the form should submit.
# getComponent() @returns {string} @public
Returns component name.
# getFormKey() @returns {string} @public
Generates the form key which is used to identify the backend form when using auto-processing.
# getSchema($side) @returns {array} @public
Parameters
sidestring : converts schema tobackendorfrontendformat.
Returns form schema.
# getButtons() @returns {array} @public
Returns buttons.
# getWizard() @returns {array} @public
Returns wizard.
# getTabs() @returns {array} @public
Returns wizard.
# getMessages() @returns {array} @public
Returns messages.
# getTheme() @returns {string} @public
Returns form theme.
# getLocale() @returns {string} @public
Returns form locale.
# getLanguage() @returns {string} @public
Returns form default language.
# getLanguages() @returns {string} @public
Returns available languages for form.
# getEndpoint() @returns {string} @public
Returns submission endpoint.
# getMethod() @returns {string} @public
Returns submission method.
# getTimezone() @returns {string} @public
Returns app timezone.
# getUserTimezone() @returns {string} @public
Returns user timezone.
# getValidateOn() @returns {string} @public
Returns validateOn.
# getColumns() @returns {array} @public
Returns columns.
# getLabels() @returns {string} @public
Retrieves labels.
# getLayout() @returns {string} @public
Retrieves layout.
# getFormErrors() @returns {string} @public
Retrieves formErrors.
# toProp() @returns {string} @public
Transforms form to JSON which can be passed to the component as prop.