Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
stonebuzz committed Dec 13, 2024
1 parent f8cd751 commit 3084834
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions inc/field.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down

0 comments on commit 3084834

Please sign in to comment.