Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add an actions_no_dropbutton Element to render form actions without the dropbutton
<?php
namespace Drupal\et_article\Element;
use Drupal\Core\Render\Element\Actions;
/**
* Provides a wrapper element to render buttons for a form.
*
* Usage example:
* @code
* $form['actions'] = array('#type' => 'actions_no_dropbutton');
* $form['actions']['submit'] = array(
* '#type' => 'submit',
* '#value' => $this->t('Save'),
* );
* @endcode
*
* @RenderElement("actions_no_dropbutton")
*/
class ActionsNoDropButton extends Actions {
/**
* {@inheritdoc}
*/
public function getInfo() {
$info = parent::getInfo();
// Unset the Actions::preRenderActionsDropbutton process callback.
foreach ($info['#process'] as $key => $process) {
if ($process[1] == 'preRenderActionsDropbutton') {
unset($info['#process'][$key]);
break;
}
}
return $info;
}
}
@arshad

This comment has been minimized.

Copy link
Owner Author

@arshad arshad commented Dec 7, 2016

Usage

<?php

// Change the type of the actions.
$form['actions']['#type'] = 'actions_no_dropbutton';

Screenshot

actions_no_dropbutton

@rachellawson

This comment has been minimized.

Copy link

@rachellawson rachellawson commented Dec 7, 2016

Ah!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment