Form Collection Model is a class which keeps its data inside
(works with an array of data passed to it as a parameter) and doesn’t interact with the server.
Optional. Validator instance. By default there is used a new Validator instance.
Methods
async getData
Return values of the specified fields from the local data structure.
Parameters:
Type
Name
Description
String [ ]
fields
Optional. Form fields to get values of. By default there is returned values of all the fields.
Returns: Promise which resolves with Object with form data. It has the following structure: {field1dName: 'value1', ..., fieldNName: 'valueN'}.
async submit
Process form data(changes): validate it(by means of the validator passed in the constructor, or the default one)
and save it in the local data structure of the model. If some fields are invalid - nothing will be saved,
but the ValidationError instance will be thrown.
Parameters:
Type
Name
Description
Object
changes
Required. Changes(or new values) in the form data. Expected structure: {field1Name: 'value1', ..., fieldNName: 'valueN'}
Returns: Promise which resolves with data that was saved(duplicates the parameter passed to the method)
getValidationDependency
Return fields(Array of string values) that need to be sent additionally to validate fields specified in passed parameters.
This method is required for creating group validators(read details here).
Parameters:
Type
Name
Description
String [ ]
fields
Required. Array of fields to get their validation-dependant fields
async isValidRecord
Validate specified record by means of the validator passed in the constructor, or the default one.
Parameters:
Type
Name
Description
Object
record
Required. Record to validate. Expected structure: {field1Name: 'value1', ..., fieldNName: 'valueN'}
Returns: Promise which resolves with ValidationErrors