[eluser]jleequeen[/eluser]
@Colin
I just updated my code and the callback is still not working. It's getting totally ignored. I did what you suggested by setting up a faux field using $this->validation->set_fields(), then did a callback rule on that field. I'm not sure what I'm doing wrong but it's pretty frustrating.
Here is my updated code:
Code:
function distribution() {
$this->load->library('validation');
$rules['total_miles'] = 'trim|required|numeric';
$rules['feet_replaced'] = 'trim|required|numeric';
$rules['feet_added'] = 'trim|required|numeric';
$rules['meters_replaced'] = 'trim|required|numeric';
$rules['percent_check'] = 'callback_percent_check';
$this->validation->set_rules($rules);
$fields['percent_check'] = 'faux';
$this->validation->set_fields($fields);
if ($this->validation->run() == FALSE) {
$this->load->view('distribution');
} else {
//save some stuff to the model
redirect('somewhere');
}
}
function percent_check($str) {
if ($this->input->post('value_a') + $this->input->post('value_b') == 100) {
return TRUE;
} else {
$this->validation->set_message('percent_check', 'Estimated percentage of lines should equal 100%.');
return FALSE;
}
}
Any ideas? Sorry, I thought I had it working but alas not.