09-04-2012, 02:10 PM
[eluser]bhumes[/eluser]
set_checkbox returns ' checked="checked"' or an empty string, which is no good for us, as form_checkbox is expecting a boolean. So, I created a replacement function in my helper file. Code is below:
Basically, I am returning TRUEs and FALSEs instead of the aforementioned strings. Works perfectly. Hope this helps someone..
set_checkbox returns ' checked="checked"' or an empty string, which is no good for us, as form_checkbox is expecting a boolean. So, I created a replacement function in my helper file. Code is below:
Code:
function set_checkbox($field = '', $value = '', $default = FALSE)
{
if ( ! isset($_POST[$field]))
{
if (count($_POST) === 0 AND $default == TRUE)
{
return TRUE;
}
return FALSE;
}
$field = $_POST[$field];
if (is_array($field))
{
if ( ! in_array($value, $field))
{
return FALSE;
}
}
else
{
if (($field == '' OR $value == '') OR ($field != $value))
{
return FALSE;
}
}
return TRUE;
}
Basically, I am returning TRUEs and FALSEs instead of the aforementioned strings. Works perfectly. Hope this helps someone..