[eluser]Monarobase[/eluser]
Hello again,
Same problem as before but with radio buttons !
I solved the select problem with the form helper (form_dropdown) but now am stuck with radio buttons.
nb. I'm working from an already existing database so I can't change my DB values.
In my database I've got "Yes" or "No" for each line, and would like to set the radio button with the database value and not TRUE or FALSE.
In my helpers folder I've created MY_form_helper.php
And have added the following :
Code:
if ( ! function_exists('set_radio'))
{
function set_radio($field = '', $value = '', $default = FALSE)
{
$OBJ =& _get_validation_object();
if ($OBJ === FALSE)
{
if ( ! isset($_POST[$field]))
{
if (count($_POST) === 0 AND ($default == TRUE OR $default == $value))
{
return ' checked="checked"';
}
return '';
}
$field = $_POST[$field];
if (is_array($field))
{
if ( ! in_array($value, $field))
{
return '';
}
}
else
{
if (($field == '' OR $value == '') OR ($field != $value))
{
return '';
}
}
return ' checked="checked"';
}
return $OBJ->set_radio($field, $value, $default);
}
}
This is the bit I changed :
It was :
Code:
if (count($_POST) === 0 AND $default == TRUE)
I changed it to :
Code:
if (count($_POST) === 0 AND ($default == TRUE OR $default == $value))
Do you have an idea why this code doesn't work or even seem to change anything ?