You are here

function webform_theme_suggestions_form_element in Webform 8.5

Same name and namespace in other branches
  1. 6.x includes/webform.theme.inc \webform_theme_suggestions_form_element()

Implements hook_theme_suggestions_HOOK().

File

includes/webform.theme.inc, line 1232
Theme hooks, preprocessor, and suggestions.

Code

function webform_theme_suggestions_form_element(array $variables) {
  if (!WebformElementHelper::isWebformElement($variables['element'])) {
    return [];
  }
  $element = $variables['element'];
  $suggestions = [];

  // Add webform type suggestion.
  if (isset($element['#type'])) {
    $suggestions[] = 'form_element__webform_' . $element['#type'];
  }

  // Add radio/checkbox displayed as a button suggestion.
  // @sse webform_process_options()
  if (!empty($element['#option_display']) && $element['#option_display'] === 'button') {
    $suggestions[] = 'form_element__webform_' . $element['#type'] . '_' . $element['#option_display'];
  }
  return $suggestions;
}