Drupal 8: Remove N/A option from radio button list options

Use this CodeLet to remove "N/A" option from radio button list options.
Place this CodeLet to your custom module file(.module) or Create a Custom module for Drupal 8 as per documentation https://www.drupal.org/docs/8/creating-custom-modules


* Implementation of hook_element_info_alter
* Remove N/A option from radio button field
* @param array $types
function MYMODULE_element_info_alter(array &$types) {
if (isset($types['radios'])) {
$types['radios'][''][] = '_MYMODULE_remove_radio_na';

* remove_radio_na
* A Callback function for MYMODULE_element_info_alter
* @param array $element
* @return modified $element
function _MYMODULE_remove_radio_na($element) {
if (!empty($element['']) && $element[''] == 'field_range') {

return $element;

By saru1683 on Tue, 03/01/2017 - 11:17am

Add comment

Log in or register to post comments
QR code for this page URL This page URL