Undefined index: #type in themable_forms_theme_suggestions_form_element()

Created on 21 August 2017, over 7 years ago
Updated 6 August 2024, 5 months ago

In themable_forms_theme_suggestions_form_element hook there's not check if $variables['element']['#type'] is set.
This cause the error in subject in such cases. For example I had this problem when use "Themable form" module with Message module (https://drupal.org/project/message) in "Message Template" admin page.

This could be the patch:

/**
 * Implements hook_theme_suggestions_form_element().
 */
function themable_forms_theme_suggestions_form_element(array $variables) {
  if (!isset($variables['element']) || !isset($variables['element']['#type'])) {
    return;
  }

  $suggestions = ['form_element__type__' . $variables['element']['#type']];
  if (isset($variables['element']['#form_id'])) {
    $suggestions[] = 'form_element__form_id__' . $variables['element']['#form_id'];
    $suggestions[] = 'form_element__' . $variables['element']['#form_id'] . '__' . $variables['element']['#type'];
  }

  return $suggestions;
}
🐛 Bug report
Status

RTBC

Version

1.0

Component

Code

Created by

🇮🇹Italy g0blin79

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024