From 645685d16e5183436d61856be0c0e77bfd77c5c7 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Wed, 20 Jan 2021 18:39:18 +0100 Subject: [PATCH 1/2] FIX : Linked extrafields list --- htdocs/core/class/commonobject.class.php | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index afb6909c340..f6e21cf5e50 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6568,15 +6568,30 @@ abstract class CommonObject var parent = $(this).find("option[parent]:first").attr("parent"); var infos = parent.split(":"); var parent_list = infos[0]; - showOptions(child_list, parent_list); - - /* Activate the handler to call showOptions on each future change */ + //Hide daughters lists + if ($("#"+child_list).val() == 0 && $("#"+parent_list).val() == 0){ + $("#"+child_list).hide(); + //Show mother lists + } else if ($("#"+parent_list).val() != 0){ + $("#"+parent_list).show(); + } + //show the child list if the parent list value is selected + $("select[name=\""+parent_list+"\"]").click(function() { + if ($(this).val() != 0){ + $("#"+child_list).show() + } + }); $("select[name=\""+parent_list+"\"]").change(function() { showOptions(child_list, parent_list); + //Select the value 0 on child list on change on the parent list + $("#"+child_list).val(0).trigger("change"); + //Hide child lists if the parent value is set to 0 + if ($(this).val() == 0){ + $("#"+child_list).hide(); + } }); }); } - setListDependencies(); }); '."\n"; From af438624a6cda1888c2a0e3f4a063a155cc39cd3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Jan 2021 13:21:22 +0100 Subject: [PATCH 2/2] Update commonobject.class.php --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index a16c621a1fd..8e303ac0f1a 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7151,7 +7151,7 @@ abstract class CommonObject } }); - //When we change parent list + //When we change parent list $("select[name=\""+parent_list+"\"]").change(function() { showOptions(child_list, parent_list, orig_select[child_list]); //Select the value 0 on child list after a change on the parent list