From 1180d5b40c213fef039ed518e0d08d275fc027db Mon Sep 17 00:00:00 2001 From: UnkyBadTouch <80658878+UnkyBadTouch@users.noreply.github.com> Date: Fri, 29 Apr 2022 10:46:41 +1000 Subject: [PATCH] 'iconOptions' added - customize Icon element Added the option 'iconOptions' so you can customize the icon element i.e. 'icon' => 'fas fa-random', 'iconOptions' => [ 'data-custom' => 'custom data for icon element', ], resulting in: --- AjaxSubmitButton.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/AjaxSubmitButton.php b/AjaxSubmitButton.php index e3c7804..2837bd7 100644 --- a/AjaxSubmitButton.php +++ b/AjaxSubmitButton.php @@ -57,6 +57,7 @@ class AjaxSubmitButton extends Widget const ICON_POSITION_RIGHT = 'right'; public $ajaxOptions = []; + public $iconOptions = []; /** * @var array the HTML attributes for the widget container tag. @@ -121,7 +122,7 @@ public function run() $label = $this->encodeLabel ? Html::encode($this->label) : $this->label; if ($this->icon !== null) { - $icon = Html::tag('i', '', ['class' => $this->icon]); + $icon = Html::tag('i', '', array_merge(['class' => $this->icon], $this->iconOptions)); $label = strcasecmp($this->iconPosition, self::ICON_POSITION_LEFT) === 0 ? sprintf('%s %s', $icon, $label) : sprintf('%s %s', $label, $icon);