summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-01-13 19:16:35 +0100
committerAndrey Andreev <narf@bofh.bg>2012-01-13 19:16:35 +0100
commitcde43687ef19aa23ee6796925270961b760369f3 (patch)
tree95bca7c0f6bfe6b61a1cef879ca1ddc992d9a1e8
parent81c87cd453c61a17e28aff2cc3f4ea76d4d19c59 (diff)
Allow native PHP functions used as rules to accept an additional parameter
-rw-r--r--system/libraries/Form_validation.php2
-rw-r--r--user_guide_src/source/changelog.rst1
-rw-r--r--user_guide_src/source/libraries/form_validation.rst7
3 files changed, 6 insertions, 4 deletions
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php
index 78b1ae016..9aa07a1a8 100644
--- a/system/libraries/Form_validation.php
+++ b/system/libraries/Form_validation.php
@@ -582,7 +582,7 @@ class CI_Form_validation {
// Users can use any native PHP function call that has one param.
if (function_exists($rule))
{
- $result = $rule($postdata);
+ $result = ($param !== FALSE) ? $rule($postdata, $param) : $rule($postdata);
if ($_in_array === TRUE)
{
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 27a8b5701..7c2ee26eb 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -69,6 +69,7 @@ Release Date: Not Released
- :doc:`Form Validation library <libraries/form_validation>` changes include:
- _execute() now considers input data to be invalid if a specified rule is not found.
- Removed method is_numeric() as it exists as a native PHP function and _execute() will find and use that (the 'is_numeric' rule itself is deprecated since 1.6.1).
+ - Native PHP functions used as rules can now accept an additional parameter, other than the data itself.
- Core
diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst
index e7875bc22..999ab362c 100644
--- a/user_guide_src/source/libraries/form_validation.rst
+++ b/user_guide_src/source/libraries/form_validation.rst
@@ -321,7 +321,7 @@ password to MD5, and running the username through the "xss_clean"
function, which removes malicious data.
**Any native PHP function that accepts one parameter can be used as a
-rule, like htmlspecialchars, trim, MD5, etc.**
+rule, like htmlspecialchars, trim, md5, etc.**
.. note:: You will generally want to use the prepping functions
**after** the validation rules so if there is an error, the original
@@ -857,8 +857,9 @@ Rule Parameter Description
$this->form_validation->required($string);
-.. note:: You can also use any native PHP functions that permit one
- parameter.
+.. note:: You can also use any native PHP functions that permit up
+ to two parameters, where at least one is required (to pass
+ the field data).
******************
Prepping Reference