I have a custom validator function named productionControlValidator
.
If I set up the form like this, everything works:
this.validTest = new FormGroup({
isdrawing: new FormControl(true),
inventoryControl: new FormControl(null)
}, { validators: productionControlValidator });
However, if I set up the form using a form builder like this:
this.validTest = this.fb.group({
isdrawing: true,
inventoryControl: null
}, { validators: productionControlValidator });
where fb
is defined in the constructor as private fb: FormBuilder
,
then the validation does not work. By "does not work", I mean that the valid property of the form is not correct, and in the console I don't see the output I expect (which does show using the first method).
Am I not defining the validator correctly in the second method (and if that is the case, how should it be defined), or is there something about FormBuilder that makes the custom validator not usable?