Issue #3057581 by quiron, fhaeberle, Wim Leers, lauriii: Add support for Dropbutton variants
parent
6caa28c094
commit
e70758877b
|
@ -17,11 +17,14 @@ namespace Drupal\Core\Render\Element;
|
||||||
* Properties:
|
* Properties:
|
||||||
* - #links: An array of links to actions. See template_preprocess_links() for
|
* - #links: An array of links to actions. See template_preprocess_links() for
|
||||||
* documentation the properties of links in this array.
|
* 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:
|
* Usage Example:
|
||||||
* @code
|
* @code
|
||||||
* $form['actions']['extra_actions'] = array(
|
* $form['actions']['extra_actions'] = array(
|
||||||
* '#type' => 'dropbutton',
|
* '#type' => 'dropbutton',
|
||||||
|
* '#dropbutton_type' => 'small',
|
||||||
* '#links' => array(
|
* '#links' => array(
|
||||||
* 'simple_form' => array(
|
* 'simple_form' => array(
|
||||||
* 'title' => $this->t('Simple Form'),
|
* 'title' => $this->t('Simple Form'),
|
||||||
|
@ -60,6 +63,11 @@ class Dropbutton extends RenderElement {
|
||||||
public static function preRenderDropbutton($element) {
|
public static function preRenderDropbutton($element) {
|
||||||
$element['#attached']['library'][] = 'core/drupal.dropbutton';
|
$element['#attached']['library'][] = 'core/drupal.dropbutton';
|
||||||
$element['#attributes']['class'][] = 'dropbutton';
|
$element['#attributes']['class'][] = 'dropbutton';
|
||||||
|
|
||||||
|
if (!empty($element['#dropbutton_type'])) {
|
||||||
|
$element['#attributes']['class'][] = 'dropbutton--' . $element['#dropbutton_type'];
|
||||||
|
}
|
||||||
|
|
||||||
if (!isset($element['#theme_wrappers'])) {
|
if (!isset($element['#theme_wrappers'])) {
|
||||||
$element['#theme_wrappers'] = [];
|
$element['#theme_wrappers'] = [];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue