I have a set of radio buttons. I first check the database to see if one of the options has already been set for the user and if so add it to $attending
. If none have been set I don't want a default value. I thought I could achieve this by setting default_value
to false
. The problem I have is that when setting default_value
to false
and I submit the form without selecting an attending
option, Drupal does not give me an error saying I didn't select an option for that radio group. How do I set a default value to nothing so that Drupal gives an error when I try to submit without selecting an option?
$form['attending'] = array(
'#type' => 'radios',
'#title' => t('Will you be attending?'),
'#options' => array(
'1' => t('Yes'),
'0' => t('No'),
),
'#required' => TRUE,
'#default_value' => isset($attending) ? $attending : false,
);