From 2249b0a88da0543ba92a08c013cecc7d32c0e308 Mon Sep 17 00:00:00 2001 From: Fabian Sierra Date: Wed, 26 May 2021 19:53:20 -0300 Subject: [PATCH] #80 check if index type has value before suggestions --- lark.theme | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lark.theme b/lark.theme index c54d978..2e19983 100644 --- a/lark.theme +++ b/lark.theme @@ -146,19 +146,25 @@ function lark_form_alter(&$form, FormStateInterface $form_state, $form_id) { function lark_theme_suggestions_form_element_alter(array &$suggestions, array $variables) { $element = $variables['element']; - $suggestions[] = 'form_element__type__' . str_replace('-', '_', $element['#type']); - if (isset($element['#attributes']['data-twig-suggestion'])) { - $suggestions[] = 'form_element__type__' . str_replace('-', '_', $element['#type']) . '__' . str_replace('-', '_', $element['#attributes']['data-twig-suggestion']); + if (!empty($element['#type'])) { + $suggestions[] = 'form_element__type__' . str_replace('-', '_', $element['#type']); + if (isset($element['#attributes']['data-twig-suggestion'])) { + $suggestions[] = 'form_element__type__' . str_replace('-', '_', $element['#type']) . '__' . str_replace('-', '_', $element['#attributes']['data-twig-suggestion']); + } } if (isset($element['#form_id'])) { $suggestions[] = 'form_element__form_id__' . str_replace('-', '_', $element['#form_id']); - $suggestions[] = 'form_element__' . str_replace('-', '_', $element['#form_id']) . '__' . str_replace('-', '_', $element['#type']); + if (!empty($element['#type'])) { + $suggestions[] = 'form_element__' . str_replace('-', '_', $element['#form_id']) . '__' . str_replace('-', '_', $element['#type']); + } } if (isset($element['#views_display_id'])) { $suggestions[] = 'form_element__' . str_replace('-', '_', $element['#form_id']) . '__' . str_replace('-', '_', $element['#views_display_id']); - $suggestions[] = 'form_element__' . str_replace('-', '_', $element['#form_id']) . '__' . str_replace('-', '_', $element['#views_display_id']) . '__' . str_replace('-', '_', $element['#type']); + if (!empty($element['#type'])) { + $suggestions[] = 'form_element__' . str_replace('-', '_', $element['#form_id']) . '__' . str_replace('-', '_', $element['#views_display_id']) . '__' . str_replace('-', '_', $element['#type']); + } } }