public function FormElement::preprocessElement in Open Social 8.8
Same name and namespace in other branches
- 8.9 themes/socialbase/src/Plugin/Preprocess/FormElement.php \Drupal\socialbase\Plugin\Preprocess\FormElement::preprocessElement()
- 8 themes/socialbase/src/Plugin/Preprocess/FormElement.php \Drupal\socialbase\Plugin\Preprocess\FormElement::preprocessElement()
- 8.2 themes/socialbase/src/Plugin/Preprocess/FormElement.php \Drupal\socialbase\Plugin\Preprocess\FormElement::preprocessElement()
- 8.3 themes/socialbase/src/Plugin/Preprocess/FormElement.php \Drupal\socialbase\Plugin\Preprocess\FormElement::preprocessElement()
- 8.4 themes/socialbase/src/Plugin/Preprocess/FormElement.php \Drupal\socialbase\Plugin\Preprocess\FormElement::preprocessElement()
- 8.5 themes/socialbase/src/Plugin/Preprocess/FormElement.php \Drupal\socialbase\Plugin\Preprocess\FormElement::preprocessElement()
- 8.6 themes/socialbase/src/Plugin/Preprocess/FormElement.php \Drupal\socialbase\Plugin\Preprocess\FormElement::preprocessElement()
- 8.7 themes/socialbase/src/Plugin/Preprocess/FormElement.php \Drupal\socialbase\Plugin\Preprocess\FormElement::preprocessElement()
Preprocess the variables array if an element is present.
Parameters
\Drupal\bootstrap\Utility\Element $element: The Element object.
\Drupal\bootstrap\Utility\Variables $variables: The Variables object.
Overrides FormElement::preprocessElement
File
- themes/
socialbase/ src/ Plugin/ Preprocess/ FormElement.php, line 21
Class
- FormElement
- Pre-processes variables for the "form_element" theme hook.
Namespace
Drupal\socialbase\Plugin\PreprocessCode
public function preprocessElement(Element $element, Variables $variables) {
// Check if form element is part of
// email_notifications and add class to label.
if ($element
->hasProperty('parents') && in_array('email_notifications', $element
->getProperty('parents'))) {
$variables['label']['#attributes']['class'][] = 'control-label--wide';
}
// Tell the label it is in a switch form element.
if (!empty($variables['element']['#attributes']['data-switch'])) {
$variables['label']['#switch'] = TRUE;
}
// Use cards for the vertical tabs component.
if ($variables['element']['#type'] === 'vertical_tabs') {
$variables['attributes']['class'][] = 'card';
}
parent::preprocessElement($element, $variables);
}