summaryrefslogtreecommitdiffstats
path: root/system/libraries
diff options
context:
space:
mode:
authorRick Ellis <rick.ellis@ellislab.com>2008-09-20 06:48:14 +0200
committerRick Ellis <rick.ellis@ellislab.com>2008-09-20 06:48:14 +0200
commit53b70e19ae8685a95a5d6b7651746279d350407e (patch)
treef721cc336f838ecea644f6b118395b86f2c1e3ce /system/libraries
parent7129d4565a0a4e7b4899deb0aee1fb1d683a7bed (diff)
Added the ability to use callbacks even when a field has no data
Diffstat (limited to 'system/libraries')
-rw-r--r--system/libraries/Form_validation.php18
1 files changed, 14 insertions, 4 deletions
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php
index fe7502773..6ef11e345 100644
--- a/system/libraries/Form_validation.php
+++ b/system/libraries/Form_validation.php
@@ -479,19 +479,29 @@ class CI_Form_validation {
return;
}
-
+
// --------------------------------------------------------------------
// If the field is blank, but NOT required, no further tests are necessary
- if ( ! in_array('required', $rules, TRUE) AND is_null($postdata))
+ $callback = FALSE;
+ if ( ! in_array('required', $rules) AND is_null($postdata))
{
- return;
+ // Before we bail out, does the rule contain a callback?
+ if (preg_match("/(callback_\w+)/", implode(' ', $rules), $match))
+ {
+ $callback = TRUE;
+ $rules = (array('1' => $match[1]));
+ }
+ else
+ {
+ return;
+ }
}
// --------------------------------------------------------------------
// Isset Test. Typically this rule will only apply to checkboxes.
- if (is_null($postdata))
+ if (is_null($postdata) AND $callback == FALSE)
{
if (in_array('isset', $rules, TRUE) OR in_array('required', $rules))
{