Previously in my Angular2 RC5 app I had an input element like the following:
<input type="text" formControlName="blah" disabled/>
The intent was to make this field non-editable by the user when in edit mode; hence the disabled attribute.
After upgrading to Angular2 RC6 I'm getting the following message in the console:
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) });
However, if I follow this advice, removing my disabled attribute and replacing my FormControl with disabled set to true, then that field does not post on submission (i.e. it does not appear in form.value).
Have I coded this situation incorrectly? Is there a way for a FormControl that is disabled to be included in the forms values?
As a side note I'm actually using FormBuilder opposed to setting up each individual FormControl if that makes a difference.