Skip to content

Commit

Permalink
Merge pull request #81 from mobomo/bug/lark-80
Browse files Browse the repository at this point in the history
#80 Theme suggestions form element undefined index: #type
  • Loading branch information
carwin authored Jun 14, 2021
2 parents 67c178a + 2249b0a commit 930233c
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions lark.theme
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}
}
}

Expand Down

0 comments on commit 930233c

Please sign in to comment.