FormObject
provides a way to specify how its relationship controls will be created.
It also provides a way to define specific saving behaviour through its saving hooks. Check saving forms guide for more details.
Constructor
constructor(model: T, options: FormObjectOptions);
Properties
attributeProperties
Property | Return type |
---|
readonly attributeProperties | Map<string | symbol, PropertyOptions> |
attributePropertiesKeys
Property | Return type |
---|
readonly attributePropertiesKeys | Array<string | symbol> |
belongsToProperties
Property | Return type |
---|
readonly belongsToProperties | Map<string | symbol, PropertyOptions> |
belongsToPropertiesKeys
Property | Return type |
---|
readonly belongsToPropertiesKeys | Array<string | symbol> |
Used for defining form field group options.
Property | Return type |
---|
get formGroupOptions() | FormGroupOptions |
set formGroupOptions() | FormGroupOptions |
Used for defining class from which FormStore
will be created.
Property | Return type |
---|
get formStoreClass() | new () => FormStore<T> |
set formStoreClass() | new () => FormStore<T> |
hasManyProperties
Property | Return type |
---|
readonly hasManyProperties | Map<string | symbol, PropertyOptions> |
hasManyPropertiesKeys
Property | Return type |
---|
readonly hasManyPropertiesKeys | Array<string | symbol> |
get model
Property | Return type |
---|
get model() | T |
get options
Property | Return type |
---|
protected get options() | FormObjectOptions |
validators
Used for defining form field validators. Check validating forms guide for more details.
Property | Return type |
---|
get validators() | Record<string, ValidatorFn | Array<ValidatorFn>> |
set validators() | Record<string, ValidatorFn | Array<ValidatorFn>> |
Methods
afterSave()
Implement this method to add custom behaviour after the model is saved. Find out more.
Method | Return type |
---|
protected afterSave(model?: T, _form?: FormStore<T>) | Observable<T> |
beforeSave()
Implement this method to add custom behaviour before the actual saving is triggered. Find out more.
Method | Return type |
---|
protected beforeSave(store: FormStore<T>) | Observable<FormStore<T>> |
getModelType()
By default, getModelType(model)
will return model.constructor.name
.
Method | Return type |
---|
getModelType(model: T) | string |
getValidators()
Returns defined validators for provided attribute name.
Method | Return type |
---|
getValidators(attributeName: string) | ValidatorFn | Array<ValidatorFn> |
Returns true
if all enabled controls inside form are valid.
Method | Return type |
---|
isFormValid(form: FormStore<T>) | boolean |
reset()
Resets provided form
value to the FormObject
model
value.
Method | Return type |
---|
reset(form: FormStore<T>) | void |
save()
Required method for saving the form. Override this method to persist the model. Find out more.
Method | Return type |
---|
protected save(model: T) | Observable<T> |