Issue #3372089 by larowlan, lauriii: Remove field_ui_theme_suggestions_form_element_alter in favor of specifying the theme wrapper on the element

merge-requests/4429/head
bnjmnm 2023-07-20 15:03:54 -04:00
parent 1c7e6e6ac2
commit 5ea65c99b1
2 changed files with 3 additions and 22 deletions

View File

@ -68,9 +68,7 @@ function field_ui_theme() {
// include default form element classes.
'form_element__new_storage_type' => [
'base hook' => 'form_element',
'variables' => [
'variant' => NULL,
],
'render element' => 'element',
],
];
}
@ -227,25 +225,6 @@ function field_ui_form_field_ui_field_storage_add_form_alter(array &$form) {
$form['add']['new_storage_type']['#options'][$optgroup]['entity_reference'] = t('Other…');
}
/**
* Implements hook_theme_suggestions_HOOK_alter().
*/
function field_ui_theme_suggestions_form_element_alter(array &$suggestions, array $variables, $hook) {
// Create a template suggestions for radio items in the add field form.
if ($variables['element']['#type'] !== 'radio' || !isset($variables['element']['#name'])) {
return;
}
$names = [
'new_storage_type',
'group_field_options_wrapper',
];
if (!in_array($variables['element']['#name'], $names, TRUE)) {
return;
}
$suggestions[] = $hook . '__new_storage_type';
}
/**
* Implements hook_preprocess_HOOK().
*/

View File

@ -215,6 +215,7 @@ class FieldStorageAddForm extends FormBase {
'#parents' => ['new_storage_type'],
'#title_display' => 'before',
'#description_display' => 'before',
'#theme_wrappers' => ['form_element__new_storage_type'],
// If it is a category, set return value as the category label,
// otherwise, set it as the field type id.
'#return_value' => $display_as_group ? $val['category'] : $val['unique_identifier'],
@ -284,6 +285,7 @@ class FieldStorageAddForm extends FormBase {
foreach ($unique_definitions[$selected_field_type] as $option_key => $option) {
$radio_element = [
'#type' => 'radio',
'#theme_wrappers' => ['form_element__new_storage_type'],
'#title' => $option['label']->render(),
'#description' => [
'#theme' => 'item_list',