Coder Social home page Coder Social logo

Comments (6)

hutzelknecht avatar hutzelknecht commented on May 18, 2024

actually, what about a property called "inputAttributes", that would pass on any attributes to the input field.

<text-field type="number" input-attributes="{ step: '0.1' , min: '0'}" attribute="amount"></text-field>

and in the input template have the following:

ng-attr-step="{{ $eval(attributes.inputAttributes).step }}"
ng-attr-min="{{ $eval(attributes.inputAttributes).min  }}"
ng-attr-max="{{ $eval(attributes.inputAttributes).max  }}"

of course having a scoped variable would help avoid the ugly $eval expression

from angular-form-for.

bvaughn avatar bvaughn commented on May 18, 2024

Interesting request.

One of formFor's main initial inspirations was the idea of separating the validation rules (min/max, etc) from the view rules. That being said there are clearly some cases where I'm not doing this (input type for example). Hm.

Would you be willing to create a pull request for this? I don't have much extra time lately for feature requests but I would be happy to accept a PR.

from angular-form-for.

hutzelknecht avatar hutzelknecht commented on May 18, 2024

I see your point! So tampering with the input field should more or less be through setting validation rules. My suggestion above would mean having validation rules in two separate places - which may of course be confusing.
I will file a pull request for this and have a think about a more sophisticated approach later ;-)

from angular-form-for.

bvaughn avatar bvaughn commented on May 18, 2024

Exactly. Inputs can already be validated as numeric (validation type: number or type: integer), with min/max values (validation minimum and maximum).

That being said, I don't think your idea is bad or anything either. It's just a little bit against the spirit of the library currently.

from angular-form-for.

bvaughn avatar bvaughn commented on May 18, 2024

Hey @hutzelknecht. Now that I'm back from traveling and have given this some thought, I feel a solution that's more in the spirit of this library would have to involve the validation rules themselves (else we risk the 2 being out of sync). So what I've done is this: for numeric inputs, if the validation rules contain a minimum or maximum value, this will automatically get passed along to the inner <input>.

I realize this does not cover step size. That's mostly because I can't think of a way to specify this as a validation rule. Actually I went ahead and added support for this as well, in the same manner as above.

from angular-form-for.

bvaughn avatar bvaughn commented on May 18, 2024

FYI this feature is available in the new 4.1.7 release.

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.