[eluser]drewbee[/eluser]
set_radio determines if it is checked by default or not by passing a TRUE or FALSE to the third parameter.
I actually force the 'database' value to have a value if it is not set.
Code:
// If their is no database value, set value_1 to be the default value.
$database->value = isset($database->value) ? $database->value : 'value_2';
set_radio('radio_field', 'value_1', (($database->value == 'value_1') ? TRUE : FALSE));
set_radio('radio_field', 'value_2', (($database->value == 'value_2') ? TRUE : FALSE));
The above will cause 'value_2' radio to be checked if their is no database value. If the database value is 'value_1', the first option will be checked.
The value will be retained after the form is submited based on user selection.