Giter VIP home page Giter VIP logo

Comments (11)

bvaughn avatar bvaughn commented on May 3, 2024

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.

bvaughn avatar bvaughn commented on May 3, 2024

PS. I added a section to the validation rules wiki page covering this topic. I thought I'd already covered it. Sorry! :)

https://github.com/bvaughn/angular-form-for/wiki/Validation-Types#validating-nested-fields-dot-notation

from angular-form-for.

bvaughn avatar bvaughn commented on May 3, 2024

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.

supdegrave avatar supdegrave commented on May 3, 2024

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.

bvaughn avatar bvaughn commented on May 3, 2024

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.

zapnap avatar zapnap commented on May 3, 2024

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.

bvaughn avatar bvaughn commented on May 3, 2024

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.

zapnap avatar zapnap commented on May 3, 2024

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.

bvaughn avatar bvaughn commented on May 3, 2024

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.

zapnap avatar zapnap commented on May 3, 2024

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.

bvaughn avatar bvaughn commented on May 3, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.