I have a 2 steps wizard with a form group in it, and in first step on clicking next page button i want to check the validity of that formgroup elements those are in first step. my question is :
1 - is it better to use 2 different forms in every wizard step or use one formgroup in all steps of wizard?
2 - if i use one formgroup how can i check the part of form validity in every step?
My template code :
<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>