From 803aca262e74f4a7dcbd3b6d0c2e3f7eaa9cd3dc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Sep 2023 15:25:50 +0200 Subject: [PATCH] Fix edit colors with html5 component --- htdocs/comm/mailing/card.php | 4 ++-- htdocs/core/class/html.formother.class.php | 7 ++++--- htdocs/core/lib/functions.lib.php | 14 ++++++++++---- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index aaa946fd2fe..27af9dc5149 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -547,7 +547,7 @@ if (empty($reshook)) { $object->title = (string) GETPOST("title"); $object->sujet = (string) GETPOST("sujet"); $object->body = (string) GETPOST("bodyemail", 'restricthtml'); - $object->bgcolor = (string) GETPOST("bgcolor"); + $object->bgcolor = preg_replace('/^#/', '', (string) GETPOST("bgcolor")); $object->bgimage = (string) GETPOST("bgimage"); if (!$object->title) { @@ -641,7 +641,7 @@ if (empty($reshook)) { $mesgs = array(); $object->sujet = (string) GETPOST("sujet"); $object->body = (string) GETPOST("bodyemail", 'restricthtml'); - $object->bgcolor = (string) GETPOST("bgcolor"); + $object->bgcolor = preg_replace('/^#/', '', (string) GETPOST("bgcolor")); $object->bgimage = (string) GETPOST("bgimage"); if (!$object->sujet) { diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 8800d5a59fc..e1356fb5dec 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -825,11 +825,11 @@ class FormOther /** * Output a HTML code to select a color. Field will return an hexa color like '334455'. * - * @param string $set_color Pre-selected color + * @param string $set_color Pre-selected color with format '#......' * @param string $prefix Name of HTML field * @param string $form_name Deprecated. Not used. * @param int $showcolorbox 1=Show color code and color box, 0=Show only color code - * @param array $arrayofcolors Array of colors. Example: array('29527A','5229A3','A32929','7A367A','B1365F','0D7813') + * @param array $arrayofcolors Array of possible colors to choose in the selector. All colors are possible if empty. Example: array('29527A','5229A3','A32929','7A367A','B1365F','0D7813') * @param string $morecss Add css style into input field * @param string $setpropertyonselect Set this property after selecting a color * @param string $default Default color @@ -917,7 +917,8 @@ class FormOther '; $out .= ''; } else { - $out .= ''; + $color = ($set_color !== '' ? $set_color : ($default !== '' ? $default : 'FFFFFF')); + $out .= ''; $out .= '