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

Pristine controls stay pristine after form submit #7850

Closed
dmitrymushenko opened this issue Jun 16, 2014 · 6 comments
Closed

Pristine controls stay pristine after form submit #7850

dmitrymushenko opened this issue Jun 16, 2014 · 6 comments

Comments

@dmitrymushenko
Copy link

It seems that changing control to dirty must stand before last committed view value check in $commitViewValue function in https://github.com/angular/angular.js/blob/0ebab08e66f953397b044be9533d764961fbc9ea/src/ng/directive/input.js.
Lines 1789 - 1796 move before line 1784.

@rodyhaddad
Copy link
Contributor

At first glance, we don't want to set a field as dirty if we're not actually changing the value, so this works as expected.

Mind posting a plunkr showcasing when this is an issue?

@dmitrymushenko
Copy link
Author

In some of 1.3.0 betas it worked in such way (beta 8, I think). And it was useful for me. But You are right, maybe it is not what we expect by default.

It can be useful in case like this. For example, there is a login form. There are also two required inputs on this form: username and password. I put some css on inputs, when they are .ng-invalid-required and .ng-dirty (to show user, that they are required). If we just press "submit" on form, nothing will happen. There must be handler to show user, that username and password are required.
But if controls will become dirty on submit, there will be no need in additional handler.

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

@rodyhaddad
Copy link
Contributor

#8056 should introduce a .ng-submitted class that you'll be able to use for your scenario.

Thanks for making us aware of it! :-)

@rodyhaddad rodyhaddad modified the milestones: Backlog, Purgatory Jul 11, 2014
@rodyhaddad rodyhaddad reopened this Jul 11, 2014
@rodyhaddad
Copy link
Contributor

Let's keep this open till #8056 gets merged
You never know what will end up happening to it :-)

@dmitrymushenko
Copy link
Author

Ok :)
Thanks for attention!

@rodyhaddad
Copy link
Contributor

.ng-submitted is now a thing, woo!

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

No branches or pull requests

4 participants