You are here

function twigsuggest_theme_suggestions_form_element in Twig Template Suggester 8

Implements hook_theme_suggestions_HOOK() for form element templates.

Add suggestions, as by default none are provided.

File

./twigsuggest.module, line 157
Twig Template Suggester module hook implementations.

Code

function twigsuggest_theme_suggestions_form_element(array $variables) {
  $suggestions = [];
  $element = $variables['element'];
  if (isset($element['#id'])) {
    $suggestions[] = 'form_element__' . str_replace('-', '_', $element['#id']);
  }
  if (isset($element['#type'])) {
    $suggestions[] = 'form_element__' . $element['#type'];
  }

  // Additional module-specific container templates.
  if (isset($element['#webform_id'])) {
    $suggestions[] = 'form_element__webform__' . str_replace('-', '_', $element['#webform_id']);
  }
  return $suggestions;
}