Welcome Guest, Not a member yet? Register   Sign In
Passing multiple arguments to callback function in form_validation class
#5

[eluser]Publisher1[/eluser]
[quote author="CroNiX" date="1272656773"]CI natively only allows for a single parameter. You can either extend CI to allow for more, or use a simple solution that I have been using to get around it. For the 2nd parameter, you can do something like:
Code:
$parameter = 'first_arg' . '||' . 'second_arg' . '||' . 'third_arg';
[/quote]

Hi CroNiX

Thanks a lot for this solution. I tried to realaze it on this way, but that didn't worked for me. Then i tried whout double pipes, i tried with # and + , these two symbols has worked. I am using CI 2.1.3 , maybe this version strips the pipe in the callback funcions.

This solution worked for me :-) :

Code:
required|trim|max_length[50]|xss_clean|callback_userdata_used_and_not_mine[users++username]

Code:
public function userdata_used_and_not_mine($s_value, $s_second_callback_parameter) {
        
    // To use more additional parameters that only 1 additional for callback functions
    $a_second_callback_parameter = explode('++', $s_second_callback_parameter);

    // bla..
}


Messages In This Thread
Passing multiple arguments to callback function in form_validation class - by El Forum - 07-25-2013, 06:30 AM



Theme © iAndrew 2016 - Forum software by © MyBB