【Drupal】ラジオボタンのN/Aを消したい
「リスト(テキスト)」のフィールドタイプを作成し制限を1にして設定を保存後、
フォームの表示管理からWIDGETを「チェックボックス/ラジオボタン」に設定すると
このとき表示される「N/A」がいらないときの処理について忘れないように記しておきます。(もっといい方法あるかもしれませんが。)
カスタムモジュールのディレクトリ名を「remove_radio_list_na」としておきます。
MY_MODULE.info.yml
modules/custom/remove_radio_list_na/remove_radio_list_na.info.yml
name: Remove Radio List N/A
description: ラジオボタンにN/Aは表示しないようにします。
type: module
core: 8.x
core_version_requirement: ^8 || ^9
package: Custom
MY_MODULE.module
modules/custom/remove_radio_list_na/remove_radio_list_na.module
<?php
/**
* Implements hook_element_info_alter().
*/
function remove_radio_list_na_element_info_alter(array &$info) {
if (isset($info['radios'])) {
$info['radios']['#process'][] = 'remove_radio_na';
}
}
function remove_radio_na($element) {
if (isset($element['#field_name'])
&& ($element['#field_name'] === <フィールドのシステム内部名称>)) {
unset($element['_none']);
}
return $element;
}
Author And Source
この問題について(【Drupal】ラジオボタンのN/Aを消したい), 我々は、より多くの情報をここで見つけました https://qiita.com/ookinimaru/items/69af09d327660b3c44da著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .