Merge pull request #20145 from atm-GregM/Fix_dolGetButtonAction

FIX: function dolGetButtonAction change title if html not set
This commit is contained in:
Laurent Destailleur 2022-03-07 17:14:33 +01:00 committed by GitHub
commit 32711e5f1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10142,7 +10142,7 @@ function dolGetButtonAction($label, $html = '', $actionType = 'default', $url =
$class = 'butAction';
if ($actionType == 'danger' || $actionType == 'delete') {
$class = 'butActionDelete';
if (strpos($url, 'token=') === false) $url .= '&token='.newToken();
if (!empty($url) && strpos($url, 'token=') === false) $url .= '&token='.newToken();
}
$attr = array(
@ -10153,6 +10153,7 @@ function dolGetButtonAction($label, $html = '', $actionType = 'default', $url =
if (empty($html)) {
$html = $label;
$attr['title'] = ''; // if html not set, leave label on title is redundant
} else {
$attr['aria-label'] = $label;
}
@ -10166,6 +10167,7 @@ function dolGetButtonAction($label, $html = '', $actionType = 'default', $url =
$attr['id'] = $id;
}
// Override attr
if (!empty($params['attr']) && is_array($params['attr'])) {
foreach ($params['attr'] as $key => $value) {
@ -10179,6 +10181,11 @@ function dolGetButtonAction($label, $html = '', $actionType = 'default', $url =
}
}
// automatic add tooltip when title is detected
if (!empty($attr['title']) && !empty($attr['class']) && strpos($attr['class'], 'classfortooltip') === false) {
$attr['class'].= ' classfortooltip';
}
// Js Confirm button
if ($userRight && !empty($params['confirm'])) {
if (!is_array($params['confirm'])) {