Basic usage
#
1. Create a modelThe model will be used to populate the form.
The model must specify which properties are attribute properties (his own properties), which are belongsTo properties, and which properties are hasMany properties. For those puproses @Attribute
, @BelongsTo
, and @HasMany
decorators are provided. Find out more.
#
2. Create a form object classThe task of a specific form object is to manage forms of a specific type.
#
3. Create a form store (form)FormObject
is created out of the model. Once created, the actual form can be accessed via formObject.form
getter.
#
4. Map form store to the templateImport ReactiveFormsModule
to the parent module.
Form store can be used in a template in the same way as any other form created by Angular's FormBuilder
.
#
5. Implement a saving functionalityTo save the form (model), .save()
on a FormStore
instance should be used.
In the background, beforeSave
, save
, and afterSave
hooks from FormObject are called. Out of those three, only the save
function is mandatory (unless the saving functionality is not used). See saving guide for more details.