summaryrefslogtreecommitdiffstats
path: root/system/libraries
diff options
context:
space:
mode:
authorPhil Sturgeon <email@philsturgeon.co.uk>2011-01-05 17:33:12 +0100
committerPhil Sturgeon <email@philsturgeon.co.uk>2011-01-05 17:33:12 +0100
commitc2e9225eec976326df36b666d6baf6db29eee831 (patch)
treeace703f9c298b2b1d5f9d1f8a2289b03b8de0212 /system/libraries
parent5e16ec6b33ed6a80bf511b2bf6eb4fc5a1103c94 (diff)
parent27324cd6ae2b076d3346e3585f312f7a61a5a897 (diff)
Automated merge with http://hg.ellislab.com/CodeIgniter-Reactor
Diffstat (limited to 'system/libraries')
-rw-r--r--system/libraries/Form_validation.php37
1 files changed, 35 insertions, 2 deletions
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php
index bf3689058..f45760024 100644
--- a/system/libraries/Form_validation.php
+++ b/system/libraries/Form_validation.php
@@ -339,7 +339,13 @@ class CI_Form_validation {
}
}
- $this->_execute($row, explode('|', $row['rules']), $this->_field_data[$field]['postdata']);
+ preg_match_all('/([a-zA-Z_-]*(\[.*\])?)\|?/i', $row['rules'], $matches);
+
+ $rules = $matches[1];
+ array_pop($rules);
+ unset($matches);
+
+ $this->_execute($row, $rules, $this->_field_data[$field]['postdata']);
}
// Did we end up with any errors?
@@ -576,7 +582,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 +736,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 +902,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