Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
In CCK version 6, non-required radio button fields add an extra "N/A" option. This is a deliberate decision made by the CCK module maintainers -- see http://drupal.org/node/368771 for discussion -- but sometimes this is not what you want. Here's a helpful snippet that can be adapted to remove this extra option on CCK radio button fields for your site.
/**
* Implementation of hook_elements().
*
* This extends optionwidgets_elements() to add in additional processing.
* Note that your module must be weighted higher than optionwidgets
* for this code to take effect.
*/
function example_elements() {
$type['optionwidgets_buttons']['#process'][] = 'remove_radio_na';
return $type;
}
/**
* Unset the N/A option on option widget radio buttons.
*/
function remove_radio_na($element) {
unset($element['value']['#options']['']);
return $element;
}