From 82f040de06a19dd78a745652165c72c6903cf982 Mon Sep 17 00:00:00 2001 From: Andrew Hunt Date: Tue, 12 May 2020 11:20:07 -0400 Subject: [PATCH] crmButton: support icon=0 for no icon --- CRM/Core/Smarty/plugins/block.crmButton.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/CRM/Core/Smarty/plugins/block.crmButton.php b/CRM/Core/Smarty/plugins/block.crmButton.php index b9869e20d3..0e1c46a78e 100644 --- a/CRM/Core/Smarty/plugins/block.crmButton.php +++ b/CRM/Core/Smarty/plugins/block.crmButton.php @@ -38,9 +38,21 @@ function smarty_block_crmButton($params, $text, &$smarty) { // Always add class 'button' - fixme probably should be crm-button $params['class'] = empty($params['class']) ? 'button' : 'button ' . $params['class']; // Any FA icon works - $icon = CRM_Utils_Array::value('icon', $params, 'pencil'); + if (array_key_exists('icon', $params) && !$params['icon']) { + // icon=0 should produce a button with no icon + $iconMarkup = ''; + } + else { + $icon = $params['icon'] ?? 'fa-pencil'; + // Assume for now that all icons are Font Awesome v4.x but handle if it's + // specified + if (strpos($icon, 'fa-') !== 0) { + $icon = "fa-$icon"; + } + $iconMarkup = "  "; + } // All other params are treated as html attributes CRM_Utils_Array::remove($params, 'icon', 'p', 'q', 'a', 'f', 'h', 'fb', 'fe'); $attributes = CRM_Utils_String::htmlAttributes($params); - return "  $text"; + return "$iconMarkup$text"; } -- 2.25.1