function uikit_preprocess_form_element

8.x-3.x preprocess.inc uikit_preprocess_form_element(&$variables)

File

includes/preprocess.inc, line 270
Set up variables to be placed within the template (.html.twig) files.

Code

function uikit_preprocess_form_element(&$variables) {
  $element = $variables ['element'];
  $type = $element ['#type'];

  // Grouped form elements do not need the uk-margin class. This adds a
  // grouped variable to use in form-element.html.twig.
  $groups = isset($element ['#groups']) && is_array($element ['#groups']);
  $variables ['grouped'] = FALSE;
  if ($groups) {
    $variables ['grouped'] = TRUE;
  }

  // Perform various changes to the variables for advanced form elements.
  $form_advanced = $type == 'checkbox' || $type == 'radio';
  $variables ['label_text'] = '';
  if ($form_advanced && isset($variables ['label']['#title']) && $variables ['label']['#title'] != '') {
    $variables ['label_text'] = ['#markup' => $variables ['label']['#title']];
  }
}

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.

Log in