You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Repository navigation
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
I have <form> with inner <ng-form>
when form is submitted inner <ng-form>.$submitted is not set to true only parent
Reacted by Anthony Johnston, Michael Prentice, Hugh Anderson, Paul Garcia, Abijeet, Nathan Schulte, Tjaart van der Walt, slukianchenkopl, PraveenKumar Elankovan, Divyansh Kumar and 2 more
I don't think we should expect the inner ngForm to behave exactly like the <form> thing. I guess we could fix this one but would be cool to know what is your real-life use-case?
My rl scenario is that I have a form where I have directive that uses ng-form and inside it I also have another directive with some input fields. That second (most inner) directive requires form controller in link function and it is the form controller from the ng-form directive. I have validation messages showing on submitted form but the only form that gets $submitted flag is the most outer form. The ng-form controller has $submitted set to false and the validation messages are not shown.
Reacted by Fernando Vitor Santos Vasconcellos, scfbarbat, Sahil Nagpal, Jonathan Tougas, Schmulik Raskin, Tjaart van der Walt and PraveenKumar Elankovan
<fieldsetng-form="form"><inputname="name" requiredng-model="ctrl.model"><ng-messagesrole="alert"
for="(form.$submitted || form.name.$touched) && form.name.$error"><ng-messagewhen="required">please enter a name</ng-message></ng-messages></fieldset>
FYI: This doesn't actually work -- the root FormController has a "noop form" set as its parent; different looping and/or conditional are required.
(e.g. while (form.$$parentForm.hasOwnProperty('$submitted')) form = form.$$parentForm or such).
Note, Angular doesn't expose a static binding for FormController (or any of the types it claims to in the documentation; NgModelController included), otherwise one could use types to check the $$parentForm for real-ness.
My team got into a situation where we really needed the change from #15778, so what we did was to create a copy of our installed angular.js (say, angular-mod.js), applied the change from the PR and used npm's postinstall to overwrite the original angular.js file in node_modules (a simple cp angular-mod.js node_modules/angular/angular.js).
Activity
pkozlowski-opensource commentedon Nov 15, 2014
I don't think we should expect the inner
ngFormto behave exactly like the<form>thing. I guess we could fix this one but would be cool to know what is your real-life use-case?luboid commentedon Nov 15, 2014
Hi
I create wizard interface,
there are two directives, which I use to show errors after form is submitted
fix(form): set $submitted to true on child forms when parent is submi…
fix(form): set $submitted to true on child forms when parent is submi…
fix(form): set $submitted to true on child forms when parent is submi…
awerlang commentedon Mar 13, 2015
Another approach is using css:
or looping through all parent forms:
interstella-5555 commentedon May 21, 2015
👍 I would like to see that too
My rl scenario is that I have a form where I have directive that uses ng-form and inside it I also have another directive with some input fields. That second (most inner) directive requires form controller in link function and it is the form controller from the ng-form directive. I have validation messages showing on submitted form but the only form that gets $submitted flag is the most outer form. The ng-form controller has $submitted set to false and the validation messages are not shown.
awerlang commentedon May 21, 2015
@kwypchlo does the css I posted above solve your issue?
stryju commentedon May 21, 2015
real life use-case:
some form:
custom-fieldset.html:20 remaining items
nmschulte commentedon Apr 18, 2017
"bump"
FYI: This doesn't actually work -- the root
FormControllerhas a "noop form" set as its parent; different looping and/or conditional are required.(e.g.
while (form.$$parentForm.hasOwnProperty('$submitted')) form = form.$$parentFormor such).Note, Angular doesn't expose a static binding for
FormController(or any of the types it claims to in the documentation;NgModelControllerincluded), otherwise one could use types to check the$$parentFormfor real-ness.Larvalis commentedon Aug 21, 2017
Another workaround I used was a watch:
andremw commentedon Aug 24, 2017
My team got into a situation where we really needed the change from #15778, so what we did was to create a copy of our installed angular.js (say, angular-mod.js), applied the change from the PR and used npm's postinstall to overwrite the original angular.js file in node_modules (a simple
cp angular-mod.js node_modules/angular/angular.js).Worked like a charm.
fix(form): set $submitted to true on child forms when parent is submi…
fix(form): set $submitted to true on child forms when parent is submi…
fix(form): set $submitted to true on child forms when parent is submi…
fix(form): set $submitted to true on child forms when parent is submi…