Welcome Guest, Not a member yet? Register   Sign In
Pass extra parameter to an anonymous validation function
#1

hi,

I see in the documentation that, it is possible to pass a extra parameter to a callback function in the form validation system.
And it works.

But what about when you want to use an anonymous function instead of a callback one ? i've tried to do this way but it didn't worked

PHP Code:
$this->form_validation->set_rules('my_field[]''my_field',
 
       array(array('my_function['.$extra_parameter.']',
 
         function($value$extra_parameter)
 
         {
 
           // My code
 
         }) )); 

thanks
Reply
#2

finally it is possible to do the following with php >= 5.3 :

PHP Code:
$this->form_validation->set_rules('my_field[]''my_field',
       array(array('my_function',
         function($value) use ($extra_parameter)
         {
           // My code
         }) )); 
Reply




Theme © iAndrew 2016 - Forum software by © MyBB