Initialize a form
Parameters:
Type | Name | Description |
---|---|---|
String [ ] | settings.fields | Required. Fields list, that are required to display |
FormModel | settings.model | Required. Form model |
Object | settings.data | Optional. Preset data |
Object | settings.changes | Optional. Preset changes |
Boolean | settings.submitAll=false | Optional. Send all form for validity check |
Boolean | settings.partialErrorChecking=false | Optional. Activate partial gradual form validation |
Boolean | settings.showDependentFields=false | Optional. Mark the fields which are involved in group validation |
Subscribe on formService ‘update’ events.
Parameters:
Type | Name | Description |
---|---|---|
Function | handler | Required. An event handler which receives changes object |
handler
s arguments:
Type | Name | Description |
---|---|---|
Object | changes.data | Form data, or null if it’s absent |
Object | changes.originalData | Form data without changes |
Boolean | changes.isLoaded | Check if data loaded |
Object | changes.changes | Form changes |
Object | changes.errors | Form errors |
Boolean | changes.submitting | Check if form is being submitted |
Unsubscribe from formService ‘update’ events.
Parameters:
Type | Name | Description |
---|---|---|
Function | handler | Required. An event handler to stop listening to events |
Unsubscribe all formService ‘update’ events handlers.
Update changes of the specified form field(s). Returns promise which resolves when the field is updated. The method triggers ‘update’ event eventually
Parameters:
Type | Name | Description |
---|---|---|
String | field | Required. Field name to update. |
Any | value | Required. Value to update the field with. Can be either an event or any serializable data |
Update field value and validate form. Returns Promise which resolves with validation errors (if there are some invalid fields) or empty result. The method triggers ‘update’ event eventually
Parameters:
Type | Name | Description |
---|---|---|
String | field | Required. Field name to update. |
Any | value | Required. Value to update the field with. Can be either an event or any serializable data |
Validate form. Returns Promise which resolves with validation errors (if there are some invalid fields) or empty result. The method triggers ‘update’ event eventually
Set data(changes) in the form.
Returns Promise which resolves after data is set.
If parameter validate
is specified, the promise will resolve with validation errors
(if there are some invalid fields) or empty result.
The method triggers ‘update’ event eventually
Parameters:
Type | Name | Description |
---|---|---|
Object | data | Required. New data to be saved in the internal class structure |
Boolean | validate=false | Optional. If the data should be validated after saving(there might be kept invalid data and it’s ok) |
Send form data(changes) to the model. If the data is invalid, or there is appeared an error while sending form data to the model - the error will be thrown. If everything went well, the sent data will be returned. The method triggers ‘update’ event eventually
Set data as changes in the form and send it to the model(combines set and submit methods). The method triggers ‘update’ event eventually
Parameters:
Type | Name | Description |
---|---|---|
Object | data | Required. New data to be saved in the internal class structure and sent to the model |
Clear field error and warning mark. The method triggers ‘update’ event eventually
Parameters:
Type | Name | Description |
---|---|---|
String [ ] || String | field | Required. Field name(s) to clear error of. Accepts ether one string value, or array of string field names |
Clear form field data(changes). The method triggers ‘update’ event eventually
Parameters:
Type | Name | Description |
---|---|---|
String | field | Required. Field name to clear changes of. |
Clear all form data(changes). The method triggers ‘update’ event eventually