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

netteForms: EQUAL and RANGE validations with float value fails on czech locale #1430

Closed
janedbal opened this issue Feb 28, 2014 · 8 comments

Comments

Projects
None yet
5 participants
@janedbal
Copy link

commented Feb 28, 2014

Following code will fail on JS validation (server validation is ok). On czech locale, the visible default value in input is actually 1,1, not 1.1. There should be some JS float filtering as it is on server side.

$form->addText('float', "Float")
     ->setRequired()
     ->setDefaultValue(1.1)
     ->addRule($form::FLOAT) // filters 1,1 to 1.1 only on server side
     ->addRule($form::RANGE, "%label must be at least %d", array(1.1, NULL)); // fails 
     // also EQUAL fails

Tested on stable 2.1.1.

@Majkl578

This comment has been minimized.

Copy link
Contributor

commented Feb 28, 2014

The problem is not in float validator, it is in range validator. It uses parseFloat native function which does not handle locale variant correctly (1,1 becomes 1).

@janedbal

This comment has been minimized.

Copy link
Author

commented Feb 28, 2014

@Majkl578 Yes, problem is with Form::RANGE and Form::EQUAL, I've changed sample code and title to be more clear.

@redhead

This comment has been minimized.

Copy link
Contributor

commented Mar 3, 2014

Can I fix this bug? (as a school assignment)

@Vrtak-CZ

This comment has been minimized.

Copy link
Contributor

commented Mar 3, 2014

@redhead why not... just send PR :-)

@redhead

This comment has been minimized.

Copy link
Contributor

commented Mar 3, 2014

I am just asking in case somebody is already writing it :)

@hrach hrach added 1-bug labels Mar 4, 2014

@janedbal

This comment has been minimized.

Copy link
Author

commented Mar 20, 2014

@redhead Are you fixing it? :)

@redhead

This comment has been minimized.

Copy link
Contributor

commented Mar 20, 2014

@CasperN Yes, will send it over weekend hopefully.

@redhead

This comment has been minimized.

Copy link
Contributor

commented Mar 21, 2014

Pull requested: #1462

dg added a commit to nette/forms that referenced this issue Feb 17, 2015

dg added a commit to nette/forms that referenced this issue Feb 18, 2015

dg added a commit to nette/forms that referenced this issue Feb 18, 2015

dg added a commit to nette/forms that referenced this issue Feb 19, 2015

dg added a commit to nette/forms that referenced this issue Feb 19, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.