Passing extra data to callback. |
[eluser]Unknown[/eluser]
I found a post related to CI 1.63 that showed how to pass extra data to a call back using the following code. Code: $this->form_validation->set_rules('username', 'Username', 'callback_username_check['.$id.']'); and then you can setup your callback function to receive more than 1 argument Code: function username_check($str, $id) {} However this doesn't seem to be in the documentation. Is this bad practice or deprecated? I have seen other posts that suggest that you should use variables or post/get data within your callback in order to use data other than the form field passed however this does break encapsulation. Thanks!
[eluser]sckarlin[/eluser]
I upgraded some code to CI 2.0.0 and found that parameters to callbacks didn't work the way they used to. I found that by commenting out line 494 of Form_validation.php, my $rules weren't clobbered by the preg_match in line 492. I'm still in the early stages of experimenting with this so I don't know if this breaks other behavior. Code: // If the field is blank, but NOT required, no further tests are necessary
[eluser]sckarlin[/eluser]
Looks like someone else has noticed this, too: https://bitbucket.org/ellislab/codeignit...r-does-not |
Welcome Guest, Not a member yet? Register Sign In |