Hi
I've written a simple callback function which isn't working. My other callbacks (which are in the same library file) work fine so I guess the problem has to do with my code.
The parameter passed in the callback function takes the form of a chunk of PHP which is eval()'ed to form part of an 'if()' statement in the function itself.
Here's what's in the controller:
$this->form_validation->set_rules('rating', 'Rating','required');
$condition = $this->input->post('rating') . " != 'Excellent'";
$this->form_validation->set_rules('details', 'Details', 'required_conditional[' . htmlentities($condition) .']');
And here's the callback function itself:
function required_conditional($str, $condition)
{
if (eval(html_entity_decode($condition))) {
if ($str == '') {
$this->set_message('required_conditional', 'The %s field is required');
return FALSE;
}
else {
return TRUE;
}
}
}
Any ideas why it's not working anyone?
Thanks, Matt