From 68915798b3cef1c5237b298ddedf41dba1b6649c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20J=C3=A4hnig?= Date: Tue, 9 Apr 2019 09:52:18 +0200 Subject: [PATCH] Default model-value for the form-factory Resolves: #20 --- src/mustache/modelGenericValidators.mustache | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/mustache/modelGenericValidators.mustache b/src/mustache/modelGenericValidators.mustache index eac4e74..4722666 100644 --- a/src/mustache/modelGenericValidators.mustache +++ b/src/mustache/modelGenericValidators.mustache @@ -35,7 +35,21 @@ * The FormControlFactory for {{classname}}. */ export class FormControlFactory extends BaseFormControlFactory<{{classname}}> { - constructor(model: {{classname}}) { + + /** + * Constructor. + * + * @param model An existing model for {{classname}}. + * If given, all form-controls of the factory automatically have the value of this model. If this + * model is not given, all values are `null`. + */ + constructor( + model: {{classname}} = { + {{#vars}} + {{name}}: null, + {{/vars}} + } + ) { super(model, {{classname}}.ModelValidators); } }