Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(forms): add default updateOn values to groups and arrays #18536

Merged
merged 1 commit into from Aug 9, 2017

Conversation

Projects
None yet
6 participants
@kara
Copy link
Contributor

commented Aug 4, 2017

This PR adds support for setting default updateOn values in FormGroups and FormArrays. If you set updateOn to 'blur' at the group level, all child controls will default to 'blur', unless the child has explicitly specified a different updateOn value.

const c = new FormGroup({
   one: new FormControl()
}, {updateOn: 'blur'});

It's worth noting that parent groups will always update their value and validity immediately upon value/validity updates from children. In other words, if a group is set to update on blur and its children are individually set to update on change, the group will still update on change with its children; its default value will simply not be used.

Upcoming PRs will address:

  • Support in template-driven forms
  • Option for skipping initial validation run or more global error display configuration
  • Better support of reactive validation strategies

See more context in #18408, #18514, and the design doc.

@googlebot googlebot added the cla: yes label Aug 4, 2017

@kara kara changed the title Update form group feat(forms): add default updateOn values to groups and arrays Aug 4, 2017

@kara kara force-pushed the kara:update-form-group branch 2 times, most recently from 2194b86 to b5323b2 Aug 4, 2017

@mary-poppins

This comment has been minimized.

Copy link

commented Aug 4, 2017

@mary-poppins

This comment has been minimized.

Copy link

commented Aug 4, 2017

@mary-poppins

This comment has been minimized.

Copy link

commented Aug 4, 2017

@kara kara added the comp: forms label Aug 7, 2017

@kara kara force-pushed the kara:update-form-group branch from b5323b2 to 0372c65 Aug 7, 2017

@kara kara removed the PR state: blocked label Aug 7, 2017

@tinayuangao
Copy link
Contributor

left a comment

LGTM

dispatchEvent(input, 'input');
fixture.detectChanges();

expect(control.value).toEqual('', 'Expected value to remain unchanged until submit.');

This comment has been minimized.

Copy link
@tinayuangao

tinayuangao Aug 7, 2017

Contributor

nit: Also check the value is unchanged when blurred?

This comment has been minimized.

Copy link
@kara

kara Aug 8, 2017

Author Contributor

Oh, good point. 👌

This comment has been minimized.

Copy link
@kara

kara Aug 8, 2017

Author Contributor

Should be updated now!

@kara kara force-pushed the kara:update-form-group branch from 0372c65 to 7231271 Aug 8, 2017

@mary-poppins

This comment has been minimized.

Copy link

commented Aug 8, 2017

@IgorMinar
Copy link
Member

left a comment

please add short property-level api doc snippet

@@ -242,6 +245,10 @@ export abstract class AbstractControl {
*/
get statusChanges(): Observable<any> { return this._statusChanges; }

get updateOn(): FormHooks {

This comment has been minimized.

Copy link
@IgorMinar

IgorMinar Aug 8, 2017

Member

Please add api docs

@kara kara force-pushed the kara:update-form-group branch from 7231271 to e4695c2 Aug 8, 2017

@kara kara removed the PR action: cleanup label Aug 8, 2017

feat(forms): add default updateOn values for groups and arrays
This commit adds support for setting default `updateOn` values
in `FormGroups` and `FormArrays`. If you set `updateOn` to
’blur’` at the group level, all child controls will default to `’blur’`,
unless the child has explicitly specified a different `updateOn` value.

```
const c = new FormGroup({
   one: new FormControl()
}, {updateOn: blur});
```

 It's worth noting that parent groups will always update their value and
validity immediately upon value/validity updates from children. In other
words, if a group is set to update on blur and its children are individually
set to update on change, the group will still update on change with its
children; its default value will simply not be used.

@kara kara force-pushed the kara:update-form-group branch from e4695c2 to c838fe3 Aug 8, 2017

@mary-poppins

This comment has been minimized.

Copy link

commented Aug 8, 2017

@mary-poppins

This comment has been minimized.

Copy link

commented Aug 8, 2017

@vicb vicb merged commit ff5c58b into angular:master Aug 9, 2017

5 checks passed

ci/circleci: build Your tests passed on CircleCI!
Details
ci/circleci: lint Your tests passed on CircleCI!
Details
cla/google All necessary CLAs are signed
code-review/pullapprove Approved by all reviewer groups.
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

asnowwolf added a commit to asnowwolf/angular that referenced this pull request Aug 11, 2017

feat(forms): add default updateOn values for groups and arrays (angul…
…ar#18536)

This commit adds support for setting default `updateOn` values
in `FormGroups` and `FormArrays`. If you set `updateOn` to
’blur’` at the group level, all child controls will default to `’blur’`,
unless the child has explicitly specified a different `updateOn` value.

```
const c = new FormGroup({
   one: new FormControl()
}, {updateOn: blur});
```

 It's worth noting that parent groups will always update their value and
validity immediately upon value/validity updates from children. In other
words, if a group is set to update on blur and its children are individually
set to update on change, the group will still update on change with its
children; its default value will simply not be used.

juleskremer added a commit to juleskremer/angular that referenced this pull request Aug 26, 2017

feat(forms): add default updateOn values for groups and arrays (angul…
…ar#18536)

This commit adds support for setting default `updateOn` values
in `FormGroups` and `FormArrays`. If you set `updateOn` to
’blur’` at the group level, all child controls will default to `’blur’`,
unless the child has explicitly specified a different `updateOn` value.

```
const c = new FormGroup({
   one: new FormControl()
}, {updateOn: blur});
```

 It's worth noting that parent groups will always update their value and
validity immediately upon value/validity updates from children. In other
words, if a group is set to update on blur and its children are individually
set to update on change, the group will still update on change with its
children; its default value will simply not be used.

juleskremer added a commit to juleskremer/angular that referenced this pull request Aug 28, 2017

feat(forms): add default updateOn values for groups and arrays (angul…
…ar#18536)

This commit adds support for setting default `updateOn` values
in `FormGroups` and `FormArrays`. If you set `updateOn` to
’blur’` at the group level, all child controls will default to `’blur’`,
unless the child has explicitly specified a different `updateOn` value.

```
const c = new FormGroup({
   one: new FormControl()
}, {updateOn: blur});
```

 It's worth noting that parent groups will always update their value and
validity immediately upon value/validity updates from children. In other
words, if a group is set to update on blur and its children are individually
set to update on change, the group will still update on change with its
children; its default value will simply not be used.

@kara kara deleted the kara:update-form-group branch Oct 13, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.