Form constructor to test the #required property.
function form_test_validate_required_form($form, &$form_state) {
$options = drupal_map_assoc(array(
'foo',
'bar',
));
$validate = array(
'form_test_validate_required_form_element_validate',
);
$form['textfield'] = array(
'#type' => 'textfield',
'#title' => 'Name',
'#required' => TRUE,
'#required_error' => t('Please enter a name.'),
);
$form['checkboxes'] = array(
'#type' => 'checkboxes',
'#title' => 'Checkboxes',
'#options' => $options,
'#required' => TRUE,
'#form_test_required_error' => t('Please choose at least one option.'),
'#element_validate' => $validate,
);
$form['select'] = array(
'#type' => 'select',
'#title' => 'Select',
'#options' => $options,
'#required' => TRUE,
'#form_test_required_error' => t('Please select something.'),
'#element_validate' => $validate,
);
$form['radios'] = array(
'#type' => 'radios',
'#title' => 'Radios',
'#options' => $options,
'#required' => TRUE,
);
$form['radios_optional'] = array(
'#type' => 'radios',
'#title' => 'Radios (optional)',
'#options' => $options,
);
$form['radios_optional_default_value_false'] = array(
'#type' => 'radios',
'#title' => 'Radios (optional, with a default value of FALSE)',
'#options' => $options,
'#default_value' => FALSE,
);
$form['actions'] = array(
'#type' => 'actions',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => 'Submit',
);
return $form;
}