convert buttons without background_image attribute to et2-button-icon with name attribute instead of image

This commit is contained in:
ralf 2022-08-22 22:31:11 +02:00
parent 0775fd1a4e
commit 95f68a4b3d

View File

@ -328,14 +328,11 @@ function send_template()
if (!empty($attrs['image']) && (empty($attrs['background_image']) || $attrs['background_image'] === 'false') && if (!empty($attrs['image']) && (empty($attrs['background_image']) || $attrs['background_image'] === 'false') &&
!preg_match('/^(index|list)/', $name)) !preg_match('/^(index|list)/', $name))
{ {
$tag = 'et2-image'; $tag = 'et2-button-icon';
$attrs['src'] = $attrs['image']; if (!isset($attrs['name']))
$attrs['class'] = (!empty($attrs['class']) ? $attrs['class'].' ':'').'imageButton';
unset($attrs['image']);
// Was expected to submit. Images don't have noValidation, so add directly
if (!array_key_exists('onclick', $attrs) && empty($attrs['noSubmit']))
{ {
$attrs['onclick'] = 'this.getInstanceManager().submit(this, undefined, ' . $attrs['noValidation'] . ')'; $attrs['name'] = $attrs['image'];
unset($attrs['image']);
} }
} }
unset($attrs['background_image']); unset($attrs['background_image']);
@ -362,7 +359,7 @@ function send_template()
} }
// change all attribute-names of new et2-* widgets to camelCase, and other attribute modifications for all web-components // change all attribute-names of new et2-* widgets to camelCase, and other attribute modifications for all web-components
$str = preg_replace_callback('#<(et2|records)-([a-z-]+)\s(.*?")\s*/?>\s*<#s', static function(array $matches) $str = preg_replace_callback('#<(et2|records)-([a-z-]+)\s(.*?")\s*/?>#s', static function(array $matches)
{ {
$attrs = parseAttrs($matches[3]); $attrs = parseAttrs($matches[3]);