[eluser]adamp1[/eluser]
Code:
function set_radio($field = '', $value = '')
{
if ($field == '' OR $value == '' OR ! isset($_POST[$field]))
{
return '';
}
if ($_POST[$field] == $value)
{
return ' checked="checked"';
}
}
OK so this is the basic function to reset a radio button after a form has been submitted. What I want to ask is why does the function get the value from $_POST? Why not $this->{$field}??
Surely that would keep in with everything with the class. And also make outputting form data simpler.
Since I know many people use the hack of setting values in the validation class, so they don't have to then have ugly if statements just to either output a form return value or the value from the DB. But using the above method you can't do this for radio/checkboxs.