function public static function ActionsDropbutton::processElement

8.x-3.x ActionsDropbutton.php public static ActionsDropbutton::processElement(Element $element, FormStateInterface $form_state, array &$complete_form)

Process a specific form element.

Parameters

\Drupal\bootstrap\Utility\Element $element: The element object.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

array $complete_form: The complete form structure.

Overrides ProcessBase::processElement

Class

ActionsDropbutton
Replaces the process callback for dropbuttons on an "actions" element.

Namespace

Drupal\bootstrap\Plugin\Process

Source src/Plugin/Process/ActionsDropbutton.php (line 28)

public static function processElement(Element $element, FormStateInterface $form_state, array &$complete_form) {
  $dropbuttons = Element::create();
  foreach ($element->children(TRUE) as $key => $child) {
    if ($dropbutton = $child->getProperty('dropbutton')) {
      // If there is no dropbutton for this button group yet, create one.
      if (!isset($dropbuttons->$dropbutton)) {
        $dropbuttons->$dropbutton = ['#type' => 'dropbutton'];
      }

      $dropbuttons[$dropbutton]['#links'][$key] = ['title' => $child->getArray()];

      // Remove original child from the element so it's not rendered twice.
      $child->setProperty('printed', TRUE);
    }
  }
  $element->exchangeArray($dropbuttons->getArray() + $element->getArray());
}