I have a reactive form. When editing, I want the control to be disabled.
The following is shown:
this.myForm.controls['analysis_horizon'].disable();
However, key Analysis_horizon is no longer in my myForm.value hash.
How to disable a field with a reactive form, but keeping the value in the form hash value?
I tried [disabled] =, but I get the following:
It looks like you're using the disabled attribute with a reactive form directive. If you set disabled to true when you set up this control in your component class, the disabled attribute will actually be set in the DOM for you. We recommend using this approach to avoid 'changed after checked' errors. Example: form = new FormGroup({ first: new FormControl({value: 'Nancy', disabled: true}, Validators.required), last: new FormControl('Drew', Validators.required) });
I load data from my database when editing into form controls, but I need one field to not be allowed to change.
Tampa source share