}
formValidated () {
+ this.forceCheck()
+ if (!this.form.valid) return
+
const value: ComponentCustomConfig = this.form.getRawValue()
forkJoin([
this.customConfig = { ...config, instanceCustomHomepage: homepage }
this.updateForm()
- // Force form validation
- this.forceCheck()
+ this.markAllAsDirty()
},
error: err => this.notifier.error(err.message)
-import { FormGroup } from '@angular/forms'
+import { AbstractControl, FormGroup } from '@angular/forms'
import { wait } from '@root-helpers/utils'
import { BuildFormArgument, BuildFormDefaultValues } from '../form-validators/form-validator.model'
import { FormValidatorService } from './form-validator.service'
} while (this.form.status === 'PENDING')
}
+ protected markAllAsDirty (controlsArg?: { [ key: string ]: AbstractControl }) {
+ const controls = controlsArg || this.form.controls
+
+ for (const key of Object.keys(controls)) {
+ const control = controls[key]
+
+ if (control instanceof FormGroup) {
+ this.markAllAsDirty(control.controls)
+ continue
+ }
+
+ control.markAsDirty()
+ }
+ }
+
protected forceCheck () {
this.onStatusChanged(this.form, this.formErrors, this.validationMessages, false)
}
this.onStatusChanged(
form.controls[field] as FormGroup,
formErrors[field] as FormReactiveErrors,
- validationMessages[field] as FormReactiveValidationMessages
+ validationMessages[field] as FormReactiveValidationMessages,
+ onlyDirty
)
continue
}