diff options
author | Phil Sturgeon <email@philsturgeon.co.uk> | 2011-01-27 12:56:45 +0100 |
---|---|---|
committer | Phil Sturgeon <email@philsturgeon.co.uk> | 2011-01-27 12:56:45 +0100 |
commit | 3bb336cf1c55584bb92ed32563a9543ec7f01574 (patch) | |
tree | 76c2d963be0b7c70705369ca4a9f82946df8bba8 /system/libraries/Form_validation.php | |
parent | 7d3a1894be6b1722c668d73ce53533bb72cc237c (diff) | |
parent | 705a3eec44635f3fada8daa2886d409e6447ca12 (diff) |
Automated merge with https://bitbucket.org/ellislab/codeigniter
Diffstat (limited to 'system/libraries/Form_validation.php')
-rw-r--r-- | system/libraries/Form_validation.php | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index cbefca104..fc5b82ee3 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -171,7 +171,7 @@ class CI_Form_validation { } $this->_error_messages = array_merge($this->_error_messages, $lang); - + return $this; } @@ -191,7 +191,7 @@ class CI_Form_validation { { $this->_error_prefix = $prefix; $this->_error_suffix = $suffix; - + return $this; } @@ -576,7 +576,7 @@ class CI_Form_validation { // Strip the parameter (if exists) from the rule // Rules can contain a parameter: max_length[5] $param = FALSE; - if (preg_match("/(.*?)\[(.*?)\]/", $rule, $match)) + if (preg_match("/(.*?)\[(.*)\]/", $rule, $match)) { $rule = $match[1]; $param = $match[2]; @@ -730,6 +730,13 @@ class CI_Form_validation { return $default; } + // If the data is an array output them one at a time. + // E.g: form_input('name[]', set_value('name[]'); + if (is_array($this->_field_data[$field]['postdata'])) + { + return array_shift($this->_field_data[$field]['postdata']); + } + return $this->_field_data[$field]['postdata']; } @@ -889,6 +896,26 @@ class CI_Form_validation { // -------------------------------------------------------------------- /** + * Performs a Regular Expression match test. + * + * @access public + * @param string + * @param regex + * @return bool + */ + function regex_match($str, $regex) + { + if ( ! preg_match($regex, $str)) + { + return FALSE; + } + + return TRUE; + } + + // -------------------------------------------------------------------- + + /** * Match one field to another * * @access public |