Welcome Guest, Not a member yet? Register   Sign In
Problems with the new Form Validation library
#1

[eluser]Bramme[/eluser]
Okay, I'm running into some problems with the new Form validation library. I'm not sure if it's bugs or if I'm doing smth wrong, so I'd like to post here first.

First up: using a config file to set rules. I changed a field name from "name" to "username", suddenly validation says the field isn't set. When I move the config array to my controller and use set_rules() everything is fine.

A second problem I have is with custom callbacks: I made a callback "unique_username" though I don't like the idea of placing it in my controller so I extend the form_validation library with MY_form_validation.php, however nothing worked. I eventually found out you have to use MY_Form_validation.php. I dunno if this is a bug or not, but I really think CI should be a little bit less harsh on upper/lower case naming conventions.
#2

[eluser]Bramme[/eluser]
I'm gonna bump this a little so it doesn't get moved to the second page and is lost forever, never to be answered...

Nobody got a clue what's happening?
#3

[eluser]xwero[/eluser]
1. you can check if the right configuration is passed on to the run method when you do
Code:
print_r($this->form_validation->_field_data);

2. It's not a bug it is to reduce the checking of files which is better for performance. If you allow a capitalized first letter of the name or a lowercased name you have to do something like
Code:
$filename_array = array(strtolower($filename),ucfirst(strtolower($filename));
$actual_filename = '';

foreach($filename_array as $test)
{
   if(is_file($test))
   {
      $actual_filename = $test;
      break;
   }
}

if(empty($actual_filename))
{
   return;
}
instead of
Code:
$filename = ucfirst(strtolower($filename);

if( ! is_file($filename))
{
   return;
}
#4

[eluser]Bramme[/eluser]
When I print and submit I get nothing, when I use the set_rules() function, I get the array with my fields.

note though: set_value() still doesn't work.
#5

[eluser]xwero[/eluser]
you have to put the print_r function after the run method is called.
#6

[eluser]Bramme[/eluser]
[quote author="xwero" date="1224521045"]you have to put the print_r function after the run method is called.[/quote]
Doesn't make a difference in my app: when the page is new, I just get an empty array, when I submit it, the array gets filled with rules and so. Which is the way the library works:
Code:
// No reason to set rules if we have no POST data
if (count($_POST) == 0)
{
    return;
}

However, this only happens when I set the array with the set_rules function. When I use the config file group it fails. I wanted to enable debug logging, but my shite shared host crashes when I enable logging.

I really should develop on my localhost, but I can't seem to get mod_rewrite to work.
#7

[eluser]xwero[/eluser]
Another way to check if the group you want is loaded is
Code:
print_r($this->form_validation->_config_rules);
#8

[eluser]Bramme[/eluser]
That one just stays empty, even if validation is working! Weird stuff.
#9

[eluser]xwero[/eluser]
It seems they still have a lot of work on the new validation library before it is released.
#10

[eluser]Bramme[/eluser]
Apparently yeah, I'm gonna revert to the current CI version I think.




Theme © iAndrew 2016 - Forum software by © MyBB