From 5e7121a9add701cebf5164bf3c7de83384b2b850 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 10 Dec 2021 16:20:30 +0100 Subject: [PATCH] Dropdown::addLink(): Allow to pass additional attributes --- src/Widget/Dropdown.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Widget/Dropdown.php b/src/Widget/Dropdown.php index b6eb20d1..0311d11d 100644 --- a/src/Widget/Dropdown.php +++ b/src/Widget/Dropdown.php @@ -46,12 +46,18 @@ public function __construct($content, $attributes = null) * @param mixed $content * @param Url|string $url * @param string $icon + * @param array $attributes * * @return $this */ - public function addLink($content, $url, $icon = null) + public function addLink($content, $url, $icon = null, array $attributes = null) { - $this->links[] = new ActionLink($content, $url, $icon, ['class' => 'dropdown-item']); + $link = new ActionLink($content, $url, $icon, ['class' => 'dropdown-item']); + if (! empty($attributes)) { + $link->addAttributes($attributes); + } + + $this->links[] = $link; return $this; }