fix(forms): make setDisabledState optional for custom comps #11731

Merged
merged 1 commit into from Sep 19, 2016

Conversation

Projects
None yet
5 participants
@kara
Contributor

kara commented Sep 19, 2016

Closes #11719

r: @vsavkin

@kara kara changed the title from fix(forms): make setDisabledState really optional for custom comps to fix(forms): make setDisabledState optional for custom comps Sep 19, 2016

@alexeagle alexeagle merged commit 51d73d3 into angular:master Sep 19, 2016

3 checks passed

ci/circleci Your tests passed on CircleCI!
Details
cla/google All necessary CLAs are signed
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@kara kara added the comp: forms label Sep 20, 2016

@mseemann mseemann referenced this pull request in mseemann/angular2-mdl Sep 24, 2016

Closed

Reactive Forms Disabled not handled #104

@aminebizid

This comment has been minimized.

Show comment
Hide comment
@aminebizid

aminebizid Sep 27, 2016

@kara
When setting a formControl disabled, it don't appear in form.value

setTimeout(() => {
this.formTask = new FormGroup({
id: new FormControl({ value: task.id, disabled: disabled }),
guid: new FormControl({ value: task.guid, disabled: disabled }),
activityId: new FormControl(task.activityId, Validators.required),
taskTypeId: new FormControl({
value: task.taskTypeId,
disabled: true
}, Validators.required),

name: new FormControl({ value: task.name, disabled: disabled }),
startDate: new FormControl({
value: task.startDate,
disabled: disabled
}, Validators.required),
endDate: new FormControl({ value: task.endDate, disabled: disabled }),
resources: new FormControl({ value: task.taskResources, disabled: disabled })
});
this.formTask.valueChanges.subscribe(() => this.isModified = true);
});,

{{formTask.value | json}}

{ "id": 3, "activityId": 5, "name": "IHM", "startDate": "2016-09-26T00:00:00.000Z", "endDate": "2017-09-26T00:00:00.000Z", "resources": [ { "id": 1, "resourceId": 1676, "startDate": "2016-09-26T14:52:18.780Z", "endDate": "2016-10-26T14:52:18.780Z", "load": 20.5 } ] }

@kara
When setting a formControl disabled, it don't appear in form.value

setTimeout(() => {
this.formTask = new FormGroup({
id: new FormControl({ value: task.id, disabled: disabled }),
guid: new FormControl({ value: task.guid, disabled: disabled }),
activityId: new FormControl(task.activityId, Validators.required),
taskTypeId: new FormControl({
value: task.taskTypeId,
disabled: true
}, Validators.required),

name: new FormControl({ value: task.name, disabled: disabled }),
startDate: new FormControl({
value: task.startDate,
disabled: disabled
}, Validators.required),
endDate: new FormControl({ value: task.endDate, disabled: disabled }),
resources: new FormControl({ value: task.taskResources, disabled: disabled })
});
this.formTask.valueChanges.subscribe(() => this.isModified = true);
});,

{{formTask.value | json}}

{ "id": 3, "activityId": 5, "name": "IHM", "startDate": "2016-09-26T00:00:00.000Z", "endDate": "2017-09-26T00:00:00.000Z", "resources": [ { "id": 1, "resourceId": 1676, "startDate": "2016-09-26T14:52:18.780Z", "endDate": "2016-10-26T14:52:18.780Z", "load": 20.5 } ] }

@aminebizid

This comment has been minimized.

Show comment
Hide comment
@aminebizid

aminebizid Sep 27, 2016

Solved when using

form.getRawValue()

Solved when using

form.getRawValue()

@kara

This comment has been minimized.

Show comment
Hide comment
@kara

kara Sep 27, 2016

Contributor

@zigzag95 This is by design. Like in native HTML5 forms, disabled form controls are not included in aggregate form value. See more detail here.

Contributor

kara commented Sep 27, 2016

@zigzag95 This is by design. Like in native HTML5 forms, disabled form controls are not included in aggregate form value. See more detail here.

@aminebizid

This comment has been minimized.

Show comment
Hide comment
@aminebizid

aminebizid Sep 27, 2016

Very helpful
Thanks

Very helpful
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment