Skip to content

Commit

Permalink
Merge pull request #1565 from danskernesdigitalebibliotek/fix-duplica…
Browse files Browse the repository at this point in the history
…te-theme-suggestion-hook

Merged logic from duplicate novel_theme_suggestions_form_element_alte…
  • Loading branch information
Dresse authored Sep 13, 2024
2 parents 88d67a5 + c2b66d7 commit 66c3622
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions web/themes/custom/novel/novel.theme
Original file line number Diff line number Diff line change
Expand Up @@ -304,17 +304,6 @@ function novel_theme_suggestions_form_alter(array &$suggestions, array $variable
}
}

/**
* Implements hook_theme_suggestions_form_element_alter().
*/
function novel_theme_suggestions_form_element_alter(array &$suggestions, array $variables): void {
$name = $variables['element']['#name'] ?? NULL;

if ($name) {
$suggestions[] = "form_element__$name";
}
}

/**
* Implements hook_theme_suggestions_input_alter().
*/
Expand Down Expand Up @@ -371,12 +360,16 @@ function novel_preprocess_views_view_unformatted(&$variables): void {
* Implements hook_theme_suggestions_HOOK_alter() for form_element.
*/
function novel_theme_suggestions_form_element_alter(array &$suggestions, array $variables): void {
$name = $variables['element']['#name'] ?? NULL;

if ($name) {
$suggestions[] = "form_element__$name";
}

if (isset($variables['element']['#webform_element']) && $variables['element']['#type'] == 'checkbox') {
// Add the template suggestion.
$suggestions[] = 'form_element__webform_checkbox';
}
if (isset($variables['element']['#webform_element']) && $variables['element']['#type'] == 'radio') {
// Add the template suggestion.
$suggestions[] = 'form_element__webform_radio';
}
}
Expand Down

0 comments on commit 66c3622

Please sign in to comment.