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

{ updateOn: 'submit' } doesn't work when using with FormBuilder's group method #20176

Closed
fiyazbinhasan opened this Issue Nov 3, 2017 · 4 comments

Comments

Projects
None yet
5 participants
@fiyazbinhasan

fiyazbinhasan commented Nov 3, 2017

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

As the documentation states: when using the { updateOn: 'submit' }, values of the FormControls should only update when a submit event on the parent FormGroup is fired. This works well when you use a new instance of FormGroup . For example,

form: FormGroup;

constructor() {
    this.form = new FormGroup({
        email: new FormControl('', [Validators.required]),
        password: new FormControl('', [Validators.required])
    }, { updateOn: 'submit' })
}

But the same example doesn't work, when using FormBuilder's group method like the following:

form: FormGroup;

constructor(private fb: FormBuilder) {
    this.form = fb.group({
        email: new FormControl('', [Validators.required]),
        password: new FormControl('', [Validators.required])
    }, { updateOn: 'submit' })
}

Expected behavior

Since the FormBuilder's group method is just a syntactic sugar that shortens new FormGroup(), in both cases it should give the exact behavior.

Minimal reproduction of the problem with instructions

You can check the bug reproduction on this plunker:

http://plnkr.co/edit/mjtIHCy3fGOVauQFc7ed?p=preview.

What is the motivation / use case for changing the behavior?

Most of the developers use the FormBuilder instead of newing up FormGroup. So, it would be nice to give them the exact behavior they want with { updateOn: 'submit' } in both cases.

Environment


Angular version: 5.0.0


Browser:
- [x] Chrome (desktop) version 61.0.3163.100
- [x] Firefox version 56.0
- [x] Edge version 40.15063.674.0
 
For Tooling issues:
- Node version: 6.10.2 
- Platform:  Windows
@Toxicable

This comment has been minimized.

Show comment
Hide comment
@Toxicable

Toxicable Nov 3, 2017

Contributor

duplicate of #19163

Contributor

Toxicable commented Nov 3, 2017

duplicate of #19163

@fiyazbinhasan fiyazbinhasan changed the title from { updateOn: 'submit' } doesn't work when using with formbuilder group to { updateOn: 'submit' } doesn't work when using with FormBuilder's group method Nov 3, 2017

@kara

This comment has been minimized.

Show comment
Hide comment
@kara

kara Nov 3, 2017

Contributor

Yep, closing as dupe. We will add support for FB down the line.

Contributor

kara commented Nov 3, 2017

Yep, closing as dupe. We will add support for FB down the line.

@kara kara closed this Nov 3, 2017

@kara kara added the comp: forms label Nov 3, 2017

@danzrou

This comment has been minimized.

Show comment
Hide comment
@danzrou

danzrou May 30, 2018

Is this solved on v6?

danzrou commented May 30, 2018

Is this solved on v6?

@rdbhagat999

This comment has been minimized.

Show comment
Hide comment
@rdbhagat999

rdbhagat999 Sep 8, 2018

Is this solved on v7?

rdbhagat999 commented Sep 8, 2018

Is this solved on v7?

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