I made a field in text list format with radio button widget and I want to remove the N/A option, but my field must be not required.

I tried this code without success.

function mymodule_element_info_alter(array &$types) {
  if (isset($types['radios'])) {
    $types['radios']['#process'][] = 'remove_radio_na';

function remove_radio_na($element) {
  if ($element['#field_name']=='field_align_image') {
  return $element;

Do you have an idea on how I can solve my issue?

  • What does “without success” mean?
    – cilefen
    Aug 26, 2022 at 11:25
  • 1
    If you remove the "N/A" option and the user clicks a radio button (thereby setting it by mistake), it will be impossible for that user to deselect the radio button, effectively making the radio button required (if the user makes a mistake). This is horrible usability. Aug 26, 2022 at 11:28
  • I usually work around this scenario by using a <select> element instead.
    – sonfd
    Aug 26, 2022 at 11:50


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.