Comments (11)
Hey Stuart,
Thanks. What you've pointed out should work. In fact, I've unit tested that exact setup pretty extensively here.
Looking at the sample code you provided, it looks like you've actually got a small typo. If your HTML is:
<form form-for="newUser" validation-rules="validationRules">
<text-field label="Email address"
attribute="credentials.userName"></text-field>
Then your validation rules should be:
$scope.validationRules = {
credentials: {
userName: {
required: true
}
So userName
instead of email
(so the two match).
I've taken the liberty of tossing up a Plunker with the code you mentioned above (typo corrected) and it seems to work as expected for me. Check it out and let me know if you're still experiencing any difficulties:
http://plnkr.co/edit/mygUyaMvdoVeKw9Ag2vD?p=preview
PS. I'd advise you also consider tacking a type: 'email'
validation onto the username field. :)
from angular-form-for.
PS. I added a section to the validation rules wiki page covering this topic. I thought I'd already covered it. Sorry! :)
from angular-form-for.
Going to close this issue since it seems like a misunderstanding rather than a bug. Please reach out to me on Github or via email if that's not the case! I'll help you figure it out. :)
from angular-form-for.
Good catch on the typo. That actually came from simplifying my code for the example.
Thanks for the reply, and for the documentation update. I'm not sure why it didn't work before, but it does now. Much appreciated!
(Hope this comment doesn't reopen the issue - I'm still getting used to GitHub's issue management. If it does, my apologies for making you close it again.)
from angular-form-for.
Sweet! I'm happy to hear that it's resolved for you. :)
Please let me know if you run into any other issues with formFor!
from angular-form-for.
Curious how you'd recommend handling nested associations. For example, a user that has many character references. Usually, this would be something like user.references[].name, user.references[].email, and so on. Thoughts?
from angular-form-for.
Ahh, that's a use-case that formFor doesn't actually support yet. It's on my (informal) roadmap but I haven't decided how to resolve it.
I think Angular's ngForm handles this by wrapping the collections with another ngForm element. (My recollection of this is a little fuzzy. I'll need to read back up on it.)
I was sort of waiting to see how many people brought up this as something they wanted me to support, and then...piece together the overlapping use-cases.
from angular-form-for.
Gotcha. Yeah, I for one, definitely need to be able to do this. I guess I'll look at how ngForm manages this.
from angular-form-for.
I'm going to need it also, I just haven't tackled it yet. Let's talk it through when you've had a chance to look at ngForm. I'm open to suggestions. :)
from angular-form-for.
I'm off to do some backpacking for the next few days so I definitely won't have a chance to look at it until Monday at the earliest, but would definitely be interested. Let me know if you get to it before then! Cheers.
from angular-form-for.
Sounds good. Have a nice time backpacking! When you return, check out #19. I'll go ahead and put my thoughts about collections there as a starting point.
from angular-form-for.
Related Issues (20)
- Can i validate HTML or other controls using Form-for HOT 21
- Form is submitted when required checkboxes are not checked HOT 8
- Feature request: never validate not-required blank/empty/unchecked inputs HOT 4
- text-field should support input filters HOT 9
- No option to add multiple custom rules to the same field HOT 4
- Checkbox Fix Release HOT 1
- Problem with latest release HOT 9
- Formatting - Select-field HOT 2
- Enable number fields HOT 6
- checkboxField change event does not fire HOT 1
- increment validation HOT 4
- Minimum/maximum rule doesn't work when number is zero HOT 9
- SelectField auto selects the last option initially HOT 6
- Plans for Angular 2? HOT 2
- Support for asynchronous schemas HOT 2
- JSON Schema support HOT 1
- Add support for latest angular-material version HOT 3
- TypeError: Cannot read property 'unwatchers' of undefined HOT 4
- The homepage is dead HOT 1
- Dynamically change validationRules depending on submit action
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular-form-for.