-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix(form): set $submitted to true on child forms when parent is submitted #11023
Conversation
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. |
@@ -276,10 +276,17 @@ function FormController(element, attrs, $scope, $animate, $interpolate) { | |||
* @description | |||
* Sets the form to its submitted state. | |||
*/ | |||
form.$setSubmitted = function() { | |||
form.$setSubmitted = function(reverse) { |
There was a problem hiding this comment.
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?
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. |
aa1e60e
to
5d39b2e
Compare
@googlebot I am indeed the author. |
5d39b2e
to
47afd65
Compare
CLAs look good, thanks! |
+1 |
@Narretz what is the status of this issue? Is there anything I can do to move this along? |
8ae27a5
to
e549f2d
Compare
👍 any chance this could be made available in 1.3.x? Or at least 1.4.x (rather than just 1.5.x) :-) |
👍 |
1.4.x yes, 1.3.x no. I just wonder if it can be considered a breaking change |
One possible middle ground would be exposing the array of controls. That way they can be iterated over in a third party plugin. |
@@ -523,6 +523,22 @@ describe('form', function() { | |||
expect(parent.$submitted).toBeTruthy(); | |||
}); | |||
|
|||
it('should set $submitted equal to true on child forms when parent is submitted', function() { | |||
doc = jqLite( | |||
'<ng:form name="parent">' + |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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
?
@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 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 |
e549f2d
to
9879ede
Compare
9879ede
to
3d0602f
Compare
@ckniffen, I wonder myself why Exposing |
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). |
will we be able to merge this before Obama leaves office? |
Let's continue discussion in #15778. I'm confident we'll resolve this before Trump is impeached. |
FormController will now call $setSubmitted on its child forms when it is submitted.
Closes #10071