Problem/Motivation

When I have check the option " Delete referenced nœuds when the parent entity is deleted." the entity is correctly delete to the form into IEF but the entity is not deleted.

Proposed resolution

@see : https://www.drupal.org/node/2491527#comment-9973909

Remaining tasks

User interface changes

None

API changes

None

Data model changes

None

Comments

woprrr’s picture

This is fix the problems ;) you can review please ?

woprrr’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 1: inline_entity_form-IEF-deleted-entites-2529114-1.patch, failed testing.

Status: Needs work » Needs review
slashrsm’s picture

Title: [Drupal8] IEF deleted entites » IEF deleted entites
Status: Needs review » Needs work

Patch doesn't fix the problem. I believe this is the reason:

+++ b/src/Plugin/Field/FieldWidget/InlineEntityFormMultiple.php
@@ -777,6 +777,9 @@ class InlineEntityFormMultiple extends InlineEntityFormBase implements Container
+      if (!empty($form_values['delete'])) {
+        $entity->delete();
+      }

We should read from field configuration instead of form state.

bojanz’s picture

We also have a whole commented out function for this:

/**
 * Implements hook_entity_delete().
 *
 * Deletes referenced entities if needed.
 *
 * @todo Remove when there's a stable contrib module for this.
 */
function inline_entity_form_entity_delete(EntityInterface $entity) {
  return;

How about removing the entire feature? It no longer feels like something a widget should do, cause that means that an API level delete won't have the same effect.

slashrsm’s picture

Another thing that also crossed my mind is the fact that the referenced entity won't be deleted if we delete parent entity. This is somewhat confusing IMO as I'd expect for both cases to behave same way.

Could we do this in a way that would also work on API level? Or is this something that should be done in a separate module that would handle this for all referenced entities?

bojanz’s picture

Separate module that integrates with entity reference, for sure.
Dave Reid already has a D7 contrib for this, though we'll probably want to revisit the approach for D8.

bojanz’s picture

Title: IEF deleted entites » Remove the "delete_references" option and functionality
Category: Bug report » Task

Retitling.

bojanz’s picture

Status: Needs work » Fixed

Done.

  • bojanz committed 39783be on 8.x-1.x
    Issue #2529114 by woprrr, bojanz: Remove the "delete_references" option...
woprrr’s picture

Assigned: woprrr » Unassigned

Hii slashrsm,

For your comment, https://www.drupal.org/node/2529114#comment-10113268

We should read from field configuration instead of form state.

I absolutely do not agree, because the configuration can display a boolean to the deletion of the entity, but we must always be able to delete the line only and not necessarily the entity in all cases. The solution to see if the user has in UX tick removal are entity makes sense for the user.

For me this ticket should be used to enable the functionality to add and the more we did commit, it is a problem from the point of view of using the plugin I think.

slashrsm’s picture

This is irrelevant now as we removed this feature from the module (see #8).

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.