From ba79d822fff2f796c65ed218515b1090a045e944 Mon Sep 17 00:00:00 2001 From: jyhere Date: Thu, 14 Mar 2024 09:58:39 +0100 Subject: [PATCH 1/3] UPDATE: add a conf param to disable extrafields code autofill I find this feature pretty annoying, so i added a misc conf global param to disable the feature. --- htdocs/core/tpl/admin_extrafields_add.tpl.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/tpl/admin_extrafields_add.tpl.php b/htdocs/core/tpl/admin_extrafields_add.tpl.php index a9fb094ed588d..19245020f26a5 100644 --- a/htdocs/core/tpl/admin_extrafields_add.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_add.tpl.php @@ -137,10 +137,12 @@ function init_typeoffields(type) }); /* Autofill the code with label */ + global->MAIN_EXTRAFIELDS_CODE_AUTOFILL_DISABLED)) : ?> jQuery("#label").keyup(function() { console.log("Update new field"); $("#attrname").val( $(this).val().replace(/[^a-zA-Z0-9_]/g, '').toLowerCase() ); }); + }); From a4d85d870671ae610a51af9ad017d679f5c3784f Mon Sep 17 00:00:00 2001 From: jyhere Date: Thu, 14 Mar 2024 10:11:54 +0100 Subject: [PATCH 2/3] UPDATE: improved extrafields code autofill Add normalize() (to convert accented chars to unaccented chars) and replace whitespaces by underscores to make the db column name more readable. --- htdocs/core/tpl/admin_extrafields_add.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/admin_extrafields_add.tpl.php b/htdocs/core/tpl/admin_extrafields_add.tpl.php index 19245020f26a5..7b8092ef81d53 100644 --- a/htdocs/core/tpl/admin_extrafields_add.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_add.tpl.php @@ -140,7 +140,7 @@ function init_typeoffields(type) global->MAIN_EXTRAFIELDS_CODE_AUTOFILL_DISABLED)) : ?> jQuery("#label").keyup(function() { console.log("Update new field"); - $("#attrname").val( $(this).val().replace(/[^a-zA-Z0-9_]/g, '').toLowerCase() ); + $("#attrname").val( $(this).val().normalize('NFD').replace(/\s/g, "_").replace(/[^a-zA-Z0-9_]/g, '').toLowerCase() ); }); }); From 0872f825eca2e55ec866fb03bf0a12a9b0407b1a Mon Sep 17 00:00:00 2001 From: jyhere Date: Fri, 15 Mar 2024 09:10:17 +0100 Subject: [PATCH 3/3] FIX: use getDolGlobalInt --- htdocs/core/tpl/admin_extrafields_add.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/admin_extrafields_add.tpl.php b/htdocs/core/tpl/admin_extrafields_add.tpl.php index 7b8092ef81d53..b06415364a68a 100644 --- a/htdocs/core/tpl/admin_extrafields_add.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_add.tpl.php @@ -137,7 +137,7 @@ function init_typeoffields(type) }); /* Autofill the code with label */ - global->MAIN_EXTRAFIELDS_CODE_AUTOFILL_DISABLED)) : ?> + jQuery("#label").keyup(function() { console.log("Update new field"); $("#attrname").val( $(this).val().normalize('NFD').replace(/\s/g, "_").replace(/[^a-zA-Z0-9_]/g, '').toLowerCase() );