Skip to main content
Version: 9.0.0

FormObject

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#

PropertyReturn type
readonly attributePropertiesMap<string | symbol, PropertyOptions>

attributePropertiesKeys#

PropertyReturn type
readonly attributePropertiesKeysArray<string | symbol>

belongsToProperties#

PropertyReturn type
readonly belongsToPropertiesMap<string | symbol, PropertyOptions>

belongsToPropertiesKeys#

PropertyReturn type
readonly belongsToPropertiesKeysArray<string | symbol>

formGroupOptions#

Used for defining form field group options.

PropertyReturn type
get formGroupOptions()FormGroupOptions
set formGroupOptions()FormGroupOptions

formStoreClass#

Used for defining class from which FormStore will be created.

PropertyReturn type
get formStoreClass()new () => FormStore<T>
set formStoreClass()new () => FormStore<T>

hasManyProperties#

PropertyReturn type
readonly hasManyPropertiesMap<string | symbol, PropertyOptions>

hasManyPropertiesKeys#

PropertyReturn type
readonly hasManyPropertiesKeysArray<string | symbol>

get model#

PropertyReturn type
get model()T

get options#

PropertyReturn type
protected get options()FormObjectOptions

validators#

Used for defining form field validators. Check validating forms guide for more details.

PropertyReturn 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.

MethodReturn 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.

MethodReturn type
protected beforeSave(store: FormStore<T>)Observable<FormStore<T>>

getModelType()#

By default, getModelType(model) will return model.constructor.name.

MethodReturn type
getModelType(model: T)string

getValidators()#

Returns defined validators for provided attribute name.

MethodReturn type
getValidators(attributeName: string)ValidatorFn | Array<ValidatorFn>

isFormValid()#

Returns true if all enabled controls inside form are valid.

MethodReturn type
isFormValid(form: FormStore<T>)boolean

reset()#

Resets provided form value to the FormObject model value.

MethodReturn type
reset(form: FormStore<T>)void

save()#

Required method for saving the form. Override this method to persist the model. Find out more.

MethodReturn type
protected save(model: T)Observable<T>