Jump to content
valan

integer field with minimal value = 0 doesn't work

Recommended Posts

Privet! I've just found that if you create integer field with minimal allowed value 0 (zero), then it doesn't save it. As a result, input accepts negative values even with HTML5 input type. Is it a bug or feature?

Share this post


Link to post
Share on other sites

Where are you setting the min in the html5 tag or is there a setting in the fieldtype? 

Share this post


Link to post
Share on other sites

Hi! I'm setting it in field admin (e.g. Setup->Fields->myIntegerField->Input->Minimum value).

Share this post


Link to post
Share on other sites

hmm, sounds like a bug, because zero is an integer. a workaround may be to leave the min blank in the fieldtype and use min="0" in the html5 tag in your template. 

<input type="number" name="quantity" min="0">

Share this post


Link to post
Share on other sites

dharmanerd, thanks! It works for own templates but doesn't work in page admin frontend. Perhaps Rayan should look at it. Thanks!

Share this post


Link to post
Share on other sites

yep, I didn't think about that and my workaround doesn't do you any good in this case. 

I had a look at the module and this is by design, but I don't think Ryan had considered the case where you may want a zero, but not negative numbers. I think it needs to be submitted as a bug.

In the meantime, try commenting line 30 in wire/core/modules/InputField/InputfieldInteger.module and let me know if that works.

  • Like 1

Share this post


Link to post
Share on other sites

Minor correction: it's wire/modules/InputField/InputfieldInteger.module

Share this post


Link to post
Share on other sites

I've had reporting this issue on my todo-list for a while.. current behavior is obviously a bit off, as there are quite a few situations where you want to allow positive numbers or a zero :)

Share this post


Link to post
Share on other sites

I'll report it and submit a patch when I get a chance. How do we report bugs? Git? 

Share this post


Link to post
Share on other sites

GitHub is great way to go. Forum is fine too, specially when you are not sure if it's a bug or not (so more people looks for it and maybe tries to reproduce).

Share this post


Link to post
Share on other sites

Hi,

On GitHub it's posted as solved, although I still get that problem with integer fields on Form Builder.

Anybody still having that problem?

Share this post


Link to post
Share on other sites
On 9/3/2018 at 4:16 AM, lenoir said:

Hi,

On GitHub it's posted as solved, although I still get that problem with integer fields on Form Builder.

Anybody still having that problem?

Bring up your Form Builder related issue in the Form Builder VIP Forum

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...