Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

fix(form): set $submitted to true on child forms when parent is submitted - #11023

Closed
ckniffen wants to merge 1 commit into
angular:masterfrom
ckniffen:nested-form-submitted
Closed

ckniffen wants to merge 1 commit into
angular:masterfrom
ckniffen:nested-form-submitted

Conversation

@ckniffen

Copy link
Copy Markdown

FormController will now call $setSubmitted on its child forms when it is submitted.

Closes #10071

@googlebot

Copy link
Copy Markdown

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.

Comment thread src/ng/directive/form.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reverse is not really a good name. How about setOnChild or something similar?

@googlebot

Copy link
Copy Markdown

We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm.

@ckniffen
ckniffen force-pushed the nested-form-submitted branch 2 times, most recently from aa1e60e to 5d39b2e Compare March 5, 2015 20:19
@ckniffen

ckniffen commented Mar 5, 2015

Copy link
Copy Markdown
Author

@googlebot I am indeed the author.

@ckniffen
ckniffen force-pushed the nested-form-submitted branch from 5d39b2e to 47afd65 Compare May 26, 2015 19:09
@googlebot

Copy link
Copy Markdown

CLAs look good, thanks!

@scottty881

Copy link
Copy Markdown

+1

@ckniffen

Copy link
Copy Markdown
Author

@Narretz what is the status of this issue? Is there anything I can do to move this along?

@kentcdodds

Copy link
Copy Markdown

👍 any chance this could be made available in 1.3.x? Or at least 1.4.x (rather than just 1.5.x) :-)

@benoror

benoror commented Sep 14, 2015

Copy link
Copy Markdown

👍

@Narretz

Narretz commented Sep 14, 2015

Copy link
Copy Markdown
Contributor

1.4.x yes, 1.3.x no. I just wonder if it can be considered a breaking change

@ckniffen

Copy link
Copy Markdown
Author

One possible middle ground would be exposing the array of controls. That way they can be iterated over in a third party plugin.

Comment thread test/ng/directive/formSpec.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please use ng-form et. al.? I think these tests are very old, that's why they use ng:form.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Narretz Should I update all the tests in this file to use ng-form?

@ckniffen

Copy link
Copy Markdown
Author

@gkalpak I looked into the the docs for the similar methods on a FormController. The current documentation for $setSubmitted says nothing about propagating. I think there is some confusion, at least for me, around the reasoning for why each method propagates the way it does.

$setDirty - goes up
$setSubmitted - goes up
$setPristine - goes down
$setUntouched - goes down

To me $setDirty makes sense to propagate up because if one child control or form is dirty then the parents are too. $setSubmitted has a similar use case as to $setPristine and $setUntouched because often times a form is made up of many nested forms which submit as one.

One alternative to making this change as I have mentioned above is to expose the controls array as $controls so that consumers of this api can write directives that are able to safely iterate over a FormController's child controls. Such a change could be leveraged by formly for example.

@ckniffen
ckniffen force-pushed the nested-form-submitted branch from e549f2d to 9879ede Compare September 23, 2015 02:14
@ckniffen
ckniffen force-pushed the nested-form-submitted branch from 9879ede to 3d0602f Compare September 23, 2015 02:24
@gkalpak

gkalpak commented Sep 25, 2015

Copy link
Copy Markdown
Member

@ckniffen, I wonder myself why $setSubmitted propagates the way it does (I don't find it intuitive, but I rarely make use of it anyway). I would be open to changing its behaviour, but it will be a breaking change so it has to be made before 1.5.0 (if at all).
Feel free to open an issue about it and see what people think.

Exposing $controls should definitely be helpful in certain scenarios, but could also be abused leading to weird and hard to debug bugs. I'm undecided about this, but would happily review a PR :)

@Narretz

Narretz commented Sep 25, 2015

Copy link
Copy Markdown
Contributor

There's no (big) rush to get this in. We'll have a few 1.5.0-beta.x releases before the 1.5.0 release (which should be the first not to contain any breaking changes).

@pbrain19

Copy link
Copy Markdown

will we be able to merge this before Obama leaves office?

@Narretz

Narretz commented Mar 6, 2017

Copy link
Copy Markdown
Contributor

Let's continue discussion in #15778. I'm confident we'll resolve this before Trump is impeached.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

$submitted is not set on sub ng-form

8 participants