stop action in predelete

Created on 23 July 2025, 9 days ago

I need help solving a small problem. I need to allow a user to delete their own webform submission, but only if a certain condition is met. I was thinking of using the predelete conten entity event, but I don't understand how to block the deletion if the condition isn't met. Thanks for any help.

💬 Support request
Status

Active

Version

2.1

Component

Documentation

Created by

🇮🇹Italy bigtomfelix

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @bigtomfelix
  • 🇩🇪Germany jurgenhaas Gottmadingen

    When the event for pre-delete is being dispatched, Drupal is already in the process of doing it and only throwing an exception would be able to stop that process.

    If you want to have a friendly control, you need to do that with access control, i.e. only providing the delete button if the conditions you mentioned are met.

  • 🇮🇹Italy bigtomfelix

    I figured the pre-delete function wouldn't work. I need to create a custom view for each user that can display their own submissions. In addition to the submission title, I also wanted to display the link to delete the submission. This link should only be visible under one condition, which I can implement with eca. But I don't understand how to combine the two.

  • 🇩🇪Germany jurgenhaas Gottmadingen

    The link to delete each row could be created with a "Views field" action. ECA would provide that as an event which receives the entity for each row where it can determine if deletion is allowed or not. If it is, it returns the link to delete that entity, otherwise it returns nothing.

    In the view you can add an extra column with the ECA Views Field. That's it.

Production build 0.71.5 2024