Welcome Guest, Not a member yet? Register   Sign In
bug and fix: new form validations (greater than, less than, decimal) do not have error messages in the language file
#1

[eluser]iateaduck[/eluser]
The new form validations on failure will say something like the error message was not found.
This is because they forgot to add the error messages to the language file.

To fix:
Go to system/language/form_validation.php

Add the following lines:

$lang['greater_than'] = "The %s field must have a value greater than %s.";
$lang['less_than'] = "The %s field must have a value lower than %s.";
$lang['decimal'] = "The %s field must be a decimal number.";

note that i havent tested decimal and the user guide is vague on how it actually works "Returns FALSE if the form element is not exactly the parameter value." (what does that mean? and what parameter does it take?)
#2

[eluser]billmce[/eluser]
Thanks for posting that ... it saved me some time. :-)

Future readers take note that if you cut-and-paste the lines above you'll have to replace the quotes ... that was my experience anyway.
#3

[eluser]victorche[/eluser]
There is no example in the user guide how to use decimal. It says, it should use parameter. That's nice, but there is no example like the other rules, which require a parameter.

Please, can somebody give an example here? What should be the parameter here?
#4

[eluser]WanWizard[/eluser]
A quick peek at the code tells me decimal doesn't need a parameter. Like 'integer', a value is either decimal (-0.00) or not.

Note that it tests hardcoded for a decimal point, which means it fails in countries that use a decimal comma.
#5

[eluser]victorche[/eluser]
[quote author="WanWizard" date="1300938993"]A quick peek at the code tells me decimal doesn't need a parameter. Like 'integer', a value is either decimal (-0.00) or not.

Note that it tests hardcoded for a decimal point, which means it fails in countries that use a decimal comma.[/quote]
Thanks, @WanWizard!
If you're right... The user guide is wrong Smile
#6

[eluser]broadband[/eluser]
@iateaduck
Thank you,

I just noticed this problem, I was about to post a problem but already you found a "bug" and solution.

I'm using it like this, x > 0 && x < 29 and can be like 4.343423(numeric).

Code:
$this->form_validation->set_rules('howmuch','Howmuch','required|numeric|greater_than[1]|less_than[29]');




Theme © iAndrew 2016 - Forum software by © MyBB