summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcosCoelho <marcos@marcoscoelho.com>2011-07-16 07:57:47 +0200
committerMarcosCoelho <marcos@marcoscoelho.com>2011-07-16 07:57:47 +0200
commit7dafce416ebbfa5a2a43c4fd40be5ab4e81bc739 (patch)
treea4d452f167f8ff0fa5b9f220cb2dd18926ad3657
parentc28b2855e572f744f66aebe1d6a09b1b2d25e8ad (diff)
explains how use a parameter/argument (optional) in your callback rule declaration
-rw-r--r--user_guide/libraries/form_validation.html13
1 files 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.</p>
<code>$this->form_validation->set_rules('username', 'Username', '<kbd>callback_username_check</kbd>');</code>
-
<p>Then add a new function called <dfn>username_check</dfn> to your controller. Here's how your controller should now look:</p>
-
-<textarea class="textarea" style="width:100%" cols="50" rows="44">&lt;?php
+<textarea class="textarea" style="width:100%" cols="50" rows="40">&lt;?php
class Form extends CI_Controller {
@@ -556,14 +554,13 @@ class Form extends CI_Controller {
<p><dfn>Reload your form and submit it with the word "test" as the username. You can see that the form field data was passed to your
callback function for you to process.</dfn></p>
-<p><strong>To invoke a callback just put the function name in a rule, with "callback_" as the rule prefix.</strong></p>
+<p>To invoke a callback just put the function name in a rule, with "callback_" as the rule <strong>prefix</strong>. If you need
+to receive an extra parameter in your callback function, just add it normally after the function name between square brackets,
+as in: "callback_foo<strong>[bar]</strong>", then it will be passed as the second argument of your callback function.</p>
-<p>You can also process the form data that is passed to your callback and return it. If your callback returns anything other than a boolean TRUE/FALSE
+<p><strong>Note:</strong> You can also process the form data that is passed to your callback and return it. If your callback returns anything other than a boolean TRUE/FALSE
it is assumed that the data is your newly processed form data.</p>
-
-
-
<a name="settingerrors"></a>
<h2>Setting Error Messages</h2>