Welcome Guest, Not a member yet? Register   Sign In
Validation depending on multiple fields?
#4

[eluser]onejaguar[/eluser]
Prepping does make it a little trickier; the result depends on which version of CI you are using.

In CI 1.6.x prep function change the $_POST values as they are called. For instance if your rules are:

Code:
$this->validation->set_rules('other_field','trim');
$this->validation->set_rules('field2','trim|callback_double_check');

Both values will be trimmed and stored in $_POST by the time double_check is called.

There is a new form validation library in CI 1.7.0 (not officially released yet) and it doesn't change $_POST until all rules and prep function have been run, so $_POST['other_field'] would not be trimmed when double_check was called. If you wanted access to the prepped variable you would use set_value(); e.g.:

Code:
return ! (empty($var) && empty($this->form_validation->set_value('other_field')))

Despite the function name set_value actually GETS the value. 1.7.0 is subject to change...


Messages In This Thread
Validation depending on multiple fields? - by El Forum - 09-26-2008, 02:02 PM
Validation depending on multiple fields? - by El Forum - 09-26-2008, 02:19 PM
Validation depending on multiple fields? - by El Forum - 09-26-2008, 02:31 PM
Validation depending on multiple fields? - by El Forum - 09-26-2008, 03:19 PM
Validation depending on multiple fields? - by El Forum - 09-29-2008, 06:10 AM



Theme © iAndrew 2016 - Forum software by © MyBB