Skip to content
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

Numeric validation errors on use of Zero "0" #4

Closed
andrewminton opened this issue Sep 29, 2011 · 7 comments
Closed

Numeric validation errors on use of Zero "0" #4

andrewminton opened this issue Sep 29, 2011 · 7 comments

Comments

@andrewminton
Copy link

Hi Brock,

Been playing a bit more and discovered that if my field is a required field and I set the validation of a field to numeric, I can't save the section due to "0" not being validated as a number.

Basically, trying to build a Quiz and have all fields with no value have a count of zero. If it's a positive value, all is well.

I'm not too hot on regex so woudln't know where to begin there.

Is this something you've encountered yet?

@brockpetrie
Copy link
Owner

Good catch. PHP likes to treat the number zero as representing an empty value. This will fix it:

Edit line 370 of fields/field.dynamictextgroup.php that says
if (!empty($field[$i])) {

Change it to:
if (!empty($field[$i]) || $field[$i] == '0') {

I'll add this fix in the next commit. Feel free to close this when you can confirm the fix works. Thanks!

@andrewminton
Copy link
Author

Hey Brock,

Tried that but still get error.. something to do with required field checkbox I'm thinking. See my screen shot. http://dl.dropbox.com/u/670078/Screen%20shot%202011-09-30%20at%2009.42.50.png

I have the numeric field with a required checkbox. I'm using latest branch.

@brockpetrie
Copy link
Owner

It looks like you aren't using the latest dev version.

Version 2.0dev6 fixes the following issue...
Fixed validation pattern presets (backslashes weren't being escaped)

You can read me and Nils' discussion about this here; I'm pretty sure this is what's causing your problem.

That version also adds checkbox and radio button subfield types, so you'll be able to use those rather than doing the text input workaround you're using.

@andrewminton
Copy link
Author

Noted. Will update. 2.0dev5 in local install. Doh! (Slaphead)

@brockpetrie
Copy link
Owner

Haha no problem

@andrewminton
Copy link
Author

Will pull your branch locally and test while at the Symposium day2 tomorrow. A lot of singing praises for the work youce done here by the way. double kudos

@brockpetrie
Copy link
Owner

Wow... Thanks a lot, man— I really appreciate that! So great to hear; very, very, inspiring! To be honest, I was a bit worried that nobody would use this thing...

I wish I was there!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants