Welcome Guest, Not a member yet? Register   Sign In
Form validation - callback function question


I have a question regarding form validation with the callback function.
The documentation says that I can pass the additional parameter like this


but what if bar is not static but variable?

For example, I'm developing a sports application.
Need to enter a game details, including the tour number, into the specific tournament. Each tournament has different number of tours which is stored in the DB.
So how can I pass the tournament id to the callback function to get the higher limit? Or how can I pass already retrieved from the DB value?

Or is there any way to pass it from the form somehow?

Just pass the variable to the validation function.
$id = 'some_variable';
$this->form_validation->set_rules('field', 'Field', "required|callback_foo[$id]");

function foo($field_value, $params)
  //$params = 'some_variable';

Theme © iAndrew 2016 - Forum software by © MyBB