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. To create a FormStore
out of that FormObject
, inject or instatiate a FormObjectBuilder
in your component/service.
Use FormObjectBuilder.create
to create the FormStore
.
#
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).