Skip to content
Snippets Groups Projects

Suppress undefined index warnings

1 file
+ 6
2
Compare changes
  • Side-by-side
  • Inline
+ 6
2
@@ -12,12 +12,16 @@ use Drupal\Core\Render\Element;
* Implements hook_theme_suggestions_form_element().
*/
function themable_forms_theme_suggestions_form_element(array $variables) {
$suggestions = ['form_element__type__' . $variables['element']['#type']];
$suggestions = [];
if (isset($variables['element']['#type'])) {
$suggestions = ['form_element__type__' . $variables['element']['#type']];
}
if (isset($variables['element']['#form_id'])) {
$suggestions[] = 'form_element__form_id__' . $variables['element']['#form_id'];
}
if (isset($variables['element']['#type']) && isset($variables['element']['#form_id'])) {
$suggestions[] = 'form_element__' . $variables['element']['#form_id'] . '__' . $variables['element']['#type'];
}
return $suggestions;
}
Loading