[eluser]jprateragg[/eluser]
In my controller, I'm using this form validation rule to clean my input field:
Code:
$this->form_validation->set_rules('adjusted', 'Adjusted Value', 'trim|clean_int|default_zero');
I'm using a helper function (default_zero) to set any values to 0 if they are empty or null.
Code:
function default_zero($input) {
if($input == '' or $input == null) {
return 0;
} else {
return $input;
}
}
However, whenever the I try to submit an empty value, it never comes back 0. If I enter 0 into the field, a 0 gets returned. If I enter a number, that number gets returned. But when I leave the field blank, nothing gets returned when I was expecting a 0 to be returned. Is this a bug or am I not doing something right? Thanks!