I have a multi step form where user traverses back and forth to the form. I save the form data in service and when he comes back i use patchvalue to patch all the data to form. I tried setvalue also, but the form fields are not marked as either dirty or touched. How to i mark fields updated as dirty and touched?
this.formBuilder.pathValue(formData);
You could explicitly mark the form using markAsDirty()
& markAsTouched()
method over your form object. See API Here
this.formName.markAsDirty()
this.formName.markAsTouched()
Update
Angular 8 onwards you can use markAllAsTouched
to mark all form field as touched
this.formName.markAllAsTouched()