You are here

public static function AjaxDropbutton::preRenderDropbutton in Entity reference actions 1.x

Pre-render callback: Attaches the dropbutton library and required markup.

Overrides Dropbutton::preRenderDropbutton

File

src/Element/AjaxDropbutton.php, line 18

Class

AjaxDropbutton
Plugin annotation @RenderElement("ajax_dropbutton");

Namespace

Drupal\entity_reference_actions\Element

Code

public static function preRenderDropbutton($element) {
  $element = parent::preRenderDropbutton($element);

  // Attach #ajax events if title is a render array.
  foreach ($element['#links'] as &$link) {
    if (isset($link['title']['#ajax'])) {
      $link['title'] = RenderElement::preRenderAjaxForm($link['title']);
    }
  }
  return $element;
}