• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Form_validation class fails to locate rule-sets for certain URIs

#1
[eluser]sholsinger[/eluser]
In 1.7.0 the Form_validation::run() method will fail to match rule-sets within the config/form_validation.php if the routed URI has a third segment. The matching function merely does a trim($uri, '/'); to check if the uri matches a key in the $config array.

Code:
// Is there a validation rule for the particular URI being accessed?
$uri = ($group == '') ? trim($this->CI->uri->ruri_string(), '/') : $group;
            
if ($uri != '' AND isset($this->_config_rules[$uri]))
{
  $this->set_rules($this->_config_rules[$uri]);
}
else
{
  $this->set_rules($this->_config_rules);
}
    
// We're we able to set the rules correctly?
if (count($this->_field_data) == 0)
{
  log_message('debug', "Unable to find validation rules");
  return FALSE;
}

The above code (which is taken from the 1.7.0 source) will fail to match a rule identified by: 'controller/method' when the uri has a third segment. Example: 'http://www.example.com/controller/method/:num'

Perhaps that line ought to be:

Code:
// Is there a validation rule for the particular URI being accessed?
$uri = ($group == '') ? $this->CI->uri->rsegment(1) . '/' .$this->CI->uri->rsegment(2) : $group;


Messages In This Thread
Form_validation class fails to locate rule-sets for certain URIs - by El Forum - 02-03-2009, 03:43 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.