Issue #3057581 by quiron, fhaeberle, Wim Leers, lauriii: Add support for Dropbutton variants

merge-requests/55/head
Lauri Eskola 2019-09-20 13:54:54 +03:00
parent 6caa28c094
commit e70758877b
No known key found for this signature in database
GPG Key ID: 37E6EF00B7EEF188
1 changed files with 8 additions and 0 deletions

View File

@ -17,11 +17,14 @@ namespace Drupal\Core\Render\Element;
* Properties:
* - #links: An array of links to actions. See template_preprocess_links() for
* documentation the properties of links in this array.
* - #dropbutton_type: A string defining a type of dropbutton variant for
* styling proposes. Renders as class `dropbutton--#dropbutton_type`.
*
* Usage Example:
* @code
* $form['actions']['extra_actions'] = array(
* '#type' => 'dropbutton',
* '#dropbutton_type' => 'small',
* '#links' => array(
* 'simple_form' => array(
* 'title' => $this->t('Simple Form'),
@ -60,6 +63,11 @@ class Dropbutton extends RenderElement {
public static function preRenderDropbutton($element) {
$element['#attached']['library'][] = 'core/drupal.dropbutton';
$element['#attributes']['class'][] = 'dropbutton';
if (!empty($element['#dropbutton_type'])) {
$element['#attributes']['class'][] = 'dropbutton--' . $element['#dropbutton_type'];
}
if (!isset($element['#theme_wrappers'])) {
$element['#theme_wrappers'] = [];
}