From c28b2855e572f744f66aebe1d6a09b1b2d25e8ad Mon Sep 17 00:00:00 2001 From: Marcos Coelho Date: Tue, 5 Jul 2011 12:59:41 -0700 Subject: enable use of param in a callback rule; it's a sugestion of solution, another way can be used, this feature seems forgotten; --- system/libraries/Form_validation.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index d370d75ee..a34809e05 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -488,7 +488,7 @@ class CI_Form_validation { if ( ! in_array('required', $rules) AND is_null($postdata)) { // Before we bail out, does the rule contain a callback? - if (preg_match("/(callback_\w+)/", implode(' ', $rules), $match)) + if (preg_match("/(callback_\w+(\[.*?\])?)/", implode(' ', $rules), $match)) { $callback = TRUE; $rules = (array('1' => $match[1])); @@ -1378,4 +1378,4 @@ class CI_Form_validation { // END Form Validation Class /* End of file Form_validation.php */ -/* Location: ./system/libraries/Form_validation.php */ \ No newline at end of file +/* Location: ./system/libraries/Form_validation.php */ -- cgit v1.2.3-24-g4f1b From 7dafce416ebbfa5a2a43c4fd40be5ab4e81bc739 Mon Sep 17 00:00:00 2001 From: MarcosCoelho Date: Sat, 16 Jul 2011 02:57:47 -0300 Subject: explains how use a parameter/argument (optional) in your callback rule declaration --- user_guide/libraries/form_validation.html | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/user_guide/libraries/form_validation.html b/user_guide/libraries/form_validation.html index bba8f507e..da2f5e5e8 100644 --- a/user_guide/libraries/form_validation.html +++ b/user_guide/libraries/form_validation.html @@ -508,11 +508,9 @@ create a callback function that does that. Let's create a example of this.

$this->form_validation->set_rules('username', 'Username', 'callback_username_check'); -

Then add a new function called username_check to your controller. Here's how your controller should now look:

- -