New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

decimalfield should specify step=any #70

Closed
puterleat opened this Issue Jun 5, 2013 · 9 comments

Comments

Projects
None yet
4 participants
@puterleat

puterleat commented Jun 5, 2013

To avoid a validation error in chrome when entering decimals, the DecimalField template should specify

<input type="number" step="any" />

See: http://blog.isotoma.com/2012/03/html5-input-typenumber-and-decimalsfloats-in-chrome/

What I have done so far is this:

Added this to input.html:

{% if attrs.decimal %}step="any"{% endif %}

And created a new widget like this:

class DecimalInput(floppyforms.widgets.NumberInput):
    def __init__(self, *args, **kwargs):
        kwargs['attrs'] = {'decimal':True}
        super(DecimalWidget, self).__init__(*args, **kwargs)
@caacree

This comment has been minimized.

Contributor

caacree commented Apr 30, 2015

Not sure why this hasn't been implemented, I just ran into it as well. It's an easy fix, but should definitely be implemented into the field.

Instead of step="any", set it to be based on the number of decimal places. ie. step=".01" for decimal places=2 on the field, etc.

@gregmuellegger

This comment has been minimized.

Owner

gregmuellegger commented Apr 30, 2015

Yep that's a great idea! I think that ticket just slipped through our attention.
I would be great to have this in the project. Would you like to implement that in a pull request?

@caacree

This comment has been minimized.

Contributor

caacree commented Apr 30, 2015

I've never contributed to a project before, but I'll give it a shot. Give me a few hours and I'll be back to work it out.

@gregmuellegger

This comment has been minimized.

Owner

gregmuellegger commented Apr 30, 2015

Great that you want to give it a shot! Feel free to ask any question if you can't get along.
A good place to start is usually to write a failing test. Because then you have the confidence that the patch you are developing will do exactly what you want.

@marcoala

This comment has been minimized.

marcoala commented May 20, 2015

Stepped into this one as well, @caacree are you still working on this? I could try to write a patch for it

@gregmuellegger

This comment has been minimized.

Owner

gregmuellegger commented May 21, 2015

@marcoala Sure, go ahead :) Cheers for stepping up.

@caacree

This comment has been minimized.

Contributor

caacree commented May 21, 2015

Sorry guys, totally forgot about this until I saw it in my email this morning. Honestly slipped my mind.

Just submitted the pull request.

@caacree

This comment has been minimized.

Contributor

caacree commented Jun 2, 2015

Hey Greg, sorry about that the first time around. Let me know if the tests pass now (not sure if there's a way I can see TravisCI stuff inside Github or I need it installed myself?).

Thanks.

@gregmuellegger

This comment has been minimized.

Owner

gregmuellegger commented Jul 17, 2015

I just release django-floppyforms 1.5.0 which includes the changes for this ticket. Happy coding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment