Within my 2-step wizard, there is a form group in the first step. When the next page button is clicked on the first step, I want to validate the elements in that form group. My questions are:
1 - Would it be more effective to use 2 separate forms in each wizard step, or use one form group throughout all steps?
2 - If I opt for a single form group, how can I verify the form's validity in each step?
Below is the code snippet from my template:
<wizard #wizard navBarLayout="large-empty-symbols">
<wizard-step [canExit]="moveDirection.bind(this, formGroup.valid)" navigationSymbol="1">
<form [formGroup]="formGroup">
<input-form-control
[required]="true"
[group]="formGroup"
label="Name"
name="name"
controlId="name"
helpText="Enter the Server Unit Name"
>
</input-form-control>
<input-form-control
[required]="true"
[group]="formGroup"
label="Label"
name="label"
controlId="label"
helpText="Enter the Server Unit Label"
>
</input-form-control>
<input-form-control
[required]="false"
[group]="formGroup"
label="Description"
name="description"
controlId="description"
helpText="Enter the Server Unit Description"
>
</input-form-control>
<div class="m-portlet__foot m-portlet__foot--fit">
<div class="m-form__actions m-form__actions">
<div class="row justify-content-center">
<div class="col-lg-9 ml-lg-auto">
<button routerLink="/asset/server-unit" class="btn btn-secondary">
Cancel
</button>
<button class="btn btn-primary" (click)="checkFormValidity()"
id="next-step" type="button" nextStep>
Next
</button>
</div>
</div>
</div>
</div>
</form>
</wizard-step>
<wizard-step [canExit]="moveDirection.bind(this, formGroup.valid)" navigationSymbol="2">
<form [formGroup]="step2formGroup">
<switch-form-control
label="Enable Execution"
controlName="execution"
controlId="enable-execution"
helpText="Set Job Enable Execution state"
>
</switch-form-control>
<div class="m-portlet__foot m-portlet__foot--fit">
<div class="m-form__actions m-form__actions">
<div class="row justify-content-center">
<div class="col-lg-9 ml-lg-auto">
<button routerLink="/asset/server-unit" class="btn btn-secondary">
Cancel
</button>
<button class="btn btn-primary" id="previous-step" type="button" previousStep>
Previous
</button>
<button class="btn btn-success" (click)="registerItem()" id="submit" type="button" [loadingBtn]="promise">
{{isEdit ? "Update" : "Add"}}
</button>
</div>
</div>
</div>
</div>
</form>
</wizard-step>
</wizard>