From 30848347a219d65cc2754b5f16ae7c48c9d3b69e Mon Sep 17 00:00:00 2001 From: stonebuzz Date: Fri, 13 Dec 2024 09:16:50 +0100 Subject: [PATCH] fix --- inc/field.class.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/inc/field.class.php b/inc/field.class.php index 7aa28216..e3cd1ab0 100644 --- a/inc/field.class.php +++ b/inc/field.class.php @@ -394,15 +394,18 @@ public function pre_deleteItem() ]); if ($this->fields['type'] === 'dropdown') { - //load all container and check if another use this fields + //load all container (except current one) and check if another use this fields $container_obj = new PluginFieldsContainer(); - $all_container = $container_obj->find(); + $all_container = $container_obj->find([ + 'id' => ['!=', $this->fields['plugin_fields_containers_id']] + ]); $use_by_another = false; foreach ($all_container as $container_fields) { foreach (json_decode($container_fields['itemtypes']) as $itemtype) { - $classname = PluginFieldsContainer::getClassname($itemtype, $container_fields['name']); - if ($DB->fieldExists(getTableForItemType($classname), $this->fields['name'])) { + $dropdown_classname = PluginFieldsDropdown::getClassname($this->fields['name']); + $dropdown_fk = getForeignKeyFieldForItemType($dropdown_classname); + if ($DB->fieldExists(getTableForItemType($classname), $dropdown_fk)) { $use_by_another = true; } }