Improve code for buttons

This commit is contained in:
jose.gonzalez@pandorafms.com 2022-10-24 13:14:19 +02:00
parent 4cf92cc995
commit 9cc811a436

View File

@ -3335,16 +3335,15 @@ function html_print_submit_button($label='OK', $name='', $disabled=false, $attri
// Icon for show in button. // Icon for show in button.
$iconToUse = ''; $iconToUse = '';
$attributesOutput = '';
if (is_array($attributes) === true) { if (is_array($attributes) === true) {
$attr_array = $attributes; foreach ($attributes as $attribute => $value) {
$attributes = '';
foreach ($attr_array as $attribute => $value) {
if ($attribute === 'icon') { if ($attribute === 'icon') {
$iconToUse = $value; $iconToUse = $value;
} else if ($attribute === 'secondary') { } else if ($attribute === 'secondary') {
$secondary = true; $secondary = true;
} else { } else {
$attributes .= $attribute.'="'.$value.'" '; $attributesOutput .= $attribute.'="'.$value.'" ';
} }
} }
} else if (empty($attributes) === false && is_string($attributes) === true) { } else if (empty($attributes) === false && is_string($attributes) === true) {
@ -3374,9 +3373,10 @@ function html_print_submit_button($label='OK', $name='', $disabled=false, $attri
} }
$output = sprintf( $output = sprintf(
'<button class="submitButton%s"%s>%s%s</button>', '<button class="submitButton%s"%s%s>%s%s</button>',
$secondary, $secondary,
($disabled === true) ? ' disabled' : '', ($disabled === true) ? ' disabled' : '',
$attributesOutput,
$label, $label,
$iconDiv $iconDiv
); );
@ -3460,7 +3460,7 @@ function html_print_button($label='OK', $name='', $disabled=false, $script='', $
} }
$output = sprintf( $output = sprintf(
'<button class="inputButton %s " %s %s %s %s %s > %s </button>', '<button type="button" class="inputButton %s " %s %s %s %s %s > %s </button>',
$secondary, $secondary,
(empty($name) === false) ? ' name="'.$name.'"' : '', (empty($name) === false) ? ' name="'.$name.'"' : '',
(empty($name) === false) ? ' id="button-'.$name.'"' : '', (empty($name) === false) ? ' id="button-'.$name.'"' : '',