SimpleActions.php in Entity reference actions 1.x
File
src/Element/SimpleActions.php
View source
<?php
namespace Drupal\entity_reference_actions\Element;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Element;
use Drupal\Core\Render\Element\Actions;
class SimpleActions extends Actions {
public static function processActions(&$element, FormStateInterface $form_state, &$complete_form) {
return $element;
}
public static function preRenderActionsDropbutton(&$element, FormStateInterface $form_state, &$complete_form) {
$dropbuttons = [];
foreach (Element::children($element, TRUE) as $key) {
if (isset($element[$key]['#dropbutton'])) {
$dropbutton = $element[$key]['#dropbutton'];
if (!isset($dropbuttons[$dropbutton])) {
$dropbuttons[$dropbutton] = [
'#type' => 'ajax_dropbutton',
];
}
$dropbuttons[$dropbutton]['#links'][$key] = [
'title' => $element[$key],
];
$operations[$key] = [
'title' => $element[$key],
];
$element[$key]['#printed'] = TRUE;
}
}
return $dropbuttons + $element;
}
}