Welcome Guest, Not a member yet? Register   Sign In
passing variable into anonymous function - form validation
#1

Hello, i would ask simple question.

is there any possibility to pass own parameter into anonymous function in set_rules for form_validation like its shown in first example below or its just possible to pass it trought callback function ? Thank you

Code:
$this->load->model('admin/currency_symbols_model', 'currency_symbols');

$currency_id = 5;

$this->form_validation->set_rules('symbol_id', 'lang:symbol', array(
                       'trim', 'required',
                       array(
                               'custom_fnc_000002[' . $currency_id . ']',
                               function ($symbol_id, $currency_id)
                               {                                                                                
                                       $symbol = $this->currency_symbols->get_symbol_by_id($symbol_id);

                if ($currency_id == $symbol->currency_id)
                {
                        return TRUE;
                }

                return FALSE;
                               }
                       )
               ));
Reply


Messages In This Thread
passing variable into anonymous function - form validation - by webdeveloper - 01-06-2016, 08:40 AM



Theme © iAndrew 2016 - Forum software by © MyBB