diff options
author | Rick Ellis <rick.ellis@ellislab.com> | 2008-09-20 06:48:14 +0200 |
---|---|---|
committer | Rick Ellis <rick.ellis@ellislab.com> | 2008-09-20 06:48:14 +0200 |
commit | 53b70e19ae8685a95a5d6b7651746279d350407e (patch) | |
tree | f721cc336f838ecea644f6b118395b86f2c1e3ce /system/libraries/Form_validation.php | |
parent | 7129d4565a0a4e7b4899deb0aee1fb1d683a7bed (diff) |
Added the ability to use callbacks even when a field has no data
Diffstat (limited to 'system/libraries/Form_validation.php')
-rw-r--r-- | system/libraries/Form_validation.php | 18 |
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))
{
|