Expand button base array into a paragraph widget action button.
array $button_base: Button base render array.
array Button render array.
public static function expandButton(array $button_base) {
// Do not expand elements that do not have submit handler.
if (empty($button_base['#submit'])) {
return $button_base;
}
$button = $button_base + [
'#type' => 'submit',
'#theme_wrappers' => [
'input__submit__paragraph_action',
],
];
// Html::getId will give us '-' char in name but we want '_' for now so
// we use strtr to search&replace '-' to '_'.
$button['#name'] = strtr(Html::getId($button_base['#name']), '-', '_');
$button['#id'] = Html::getUniqueId($button['#name']);
if (isset($button['#ajax'])) {
$button['#ajax'] += [
'effect' => 'fade',
// Since a normal throbber is added inline, this has the potential to
// break a layout if the button is located in dropbuttons. Instead,
// it's safer to just show the fullscreen progress element instead.
'progress' => [
'type' => 'fullscreen',
],
];
}
return $button;
}