From 3b2803ef6ddd72772bf5bcb130ace207bc10d60e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 7 Jan 2014 14:46:38 +0200 Subject: Fix #2143 When trying to load rules from a configuration file, the Form validation library matched against ruri_string() as opposed to 'controller/method' like described in the manual. Since ruri_string() also makes sense, now both are being checked with ruri_string() having a higher precedence. Supersedes PR #2224 --- system/libraries/Form_validation.php | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index e8bd25b58..852fc7144 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -414,18 +414,15 @@ class CI_Form_validation { return FALSE; } - // Is there a validation rule for the particular URI being accessed? - $uri = ($group === '') ? trim($this->CI->uri->ruri_string(), '/') : $group; - - if ($uri !== '' && isset($this->_config_rules[$uri])) + if (empty($group)) { - $this->set_rules($this->_config_rules[$uri]); - } - else - { - $this->set_rules($this->_config_rules); + // Is there a validation rule for the particular URI being accessed? + $group = trim($this->CI->uri->ruri_string(), '/'); + isset($this->_config_rules[$group]) OR $group = $this->CI->router->class.'/'.$this->CI->router->method; } + $this->set_rules(isset($this->_config_rules[$group]) ? $this->_config_rules[$group] : $this->_config_rules); + // Were we able to set the rules correctly? if (count($this->_field_data) === 0) { -- cgit v1.2.3-24-g4f1b