You are here

public static function HtmlElement::processHtmlElement in Field Group 8

Same name and namespace in other branches
  1. 8.3 src/Element/HtmlElement.php \Drupal\field_group\Element\HtmlElement::processHtmlElement()

Process a html element

Parameters

array $element: An associative array containing the properties and children of the details element.

FormStateInterface $form_state: The current state of the form.

Return value

array The processed element.

1 call to HtmlElement::processHtmlElement()
HtmlElement::preRender in src/Plugin/field_group/FieldGroupFormatter/HtmlElement.php
Allows the field group formatter to manipulate the field group array and attach the formatters rendering element.

File

src/Element/HtmlElement.php, line 41

Class

HtmlElement
Provides a render element for a html element.

Namespace

Drupal\field_group\Element

Code

public static function processHtmlElement(&$element, FormStateInterface $form_state) {

  // If an effect is set, we need to load extra js.
  if (!empty($element['#effect']) && $element['#effect'] !== 'none') {
    $element['#attached']['library'][] = 'field_group/formatter.html_element';
    $element['#attached']['library'][] = 'field_group/core';

    // Add the required classes for the js.
    $element['#attributes']['class'][] = 'field-group-html-element';
    $element['#attributes']['class'][] = 'fieldgroup-collapsible';
    $element['#attributes']['class'][] = 'effect-' . $element['#effect'];
    if (!empty($element['#speed'])) {
      $element['#attributes']['class'][] = 'speed-' . $element['#speed'];
    }

    // Add jquery ui effects library for the blind effect.
    if ($element['#effect'] == 'blind') {
      $element['#attached']['library'][] = 'core/jquery.ui.effects.blind';
    }
  }
  return $element;
}