I use Drupal 8.8. I have a content type that includes a registration webform for events (field reference to entity). I have to give access to users who have created their own webform submissions; these users can cancel their submissions only when registrations to the event are open. (I use the open, closed, scheduled function of the webform module.) If the event registrations are closed, these users cannot cancel their submissions. How can it be done?

In a module, how can I get the status of the webform reference?

I found how to get the status of the webform reference.

use Drupal\node\Entity\Node;

function hook_maybe_views_data_alter????() {  
  $id = 2; // For example...
  $node = Node::load($id);
  $status = $node->get('field_NAME_WEBFORM_ENTITY_REFERENCE')->entity->isOpen()

Now I have to understand how to edit the page that represents the submissions. To represent submissions to events I used a view which shows the data in table form. A user can be subscribed to more events, so the rows in the table dynamically show all the events to which the user is registered.

The view includes a logged-in user filter and some fields that give information about the event. One of the fields I have included in the view is Webform submission: Link to delete Webform submission, which I use to delete the submission.

How can I modify the link to delete the submission?

In this way it would be possible on the basis of the function before (hook_maybe_views_data_alter????) to enable or not the link to delete the submission, depending on the state of the referenced weform: If open, it can be deleted, otherwise not.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.