summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
authorDerek Jones <derek.jones@ellislab.com>2008-01-18 20:50:49 +0100
committerDerek Jones <derek.jones@ellislab.com>2008-01-18 20:50:49 +0100
commit07edd4b16f8037ca5adda499c72710aaf3bdf215 (patch)
tree293602eaa9c19bf7413b0adadbfd4226788c3955 /system
parent3d879d529107c0c9d3f1e6b894d9ed17b6e6c54f (diff)
modified prep_for_form() to accept an array so POST arrays can be validated with the Validation class via callback functions and have fields properly assigned
Diffstat (limited to 'system')
-rw-r--r--system/libraries/Validation.php20
1 files changed, 14 insertions, 6 deletions
diff --git a/system/libraries/Validation.php b/system/libraries/Validation.php
index 84415030d..061cacc9c 100644
--- a/system/libraries/Validation.php
+++ b/system/libraries/Validation.php
@@ -86,8 +86,8 @@ class CI_Validation {
}
foreach($this->_fields as $key => $val)
- {
- $this->$key = ( ! isset($_POST[$key]) OR is_array($_POST[$key])) ? '' : $this->prep_for_form($_POST[$key]);
+ {
+ $this->$key = ( ! isset($_POST[$key])) ? '' : $this->prep_for_form($_POST[$key]);
$error = $key.'_error';
if ( ! isset($this->$error))
@@ -659,14 +659,22 @@ class CI_Validation {
* @param string
* @return string
*/
- function prep_for_form($str = '')
+ function prep_for_form($data = '')
{
- if ($this->_safe_form_data == FALSE OR $str == '')
+ if (is_array($data))
+ {
+ foreach ($data as $key => $val)
+ {
+ $data[$key] = $this->prep_for_form($val);
+ }
+ }
+
+ if ($this->_safe_form_data == FALSE OR $data == '')
{
- return $str;
+ return $data;
}
- return str_replace(array("'", '"', '<', '>'), array("&#39;", "&quot;", '&lt;', '&gt;'), stripslashes($str));
+ return str_replace(array("'", '"', '<', '>'), array("&#39;", "&quot;", '&lt;', '&gt;'), stripslashes($data));
}
// --------------------------------------------------------------------