Webform form is viewed

Created on 4 May 2023, almost 2 years ago
Updated 13 May 2023, almost 2 years ago

Problem/Motivation

I'm using Webform, and there is 'Webform submission is viewed' (when already submitted form is viewed), however there is no react event when form itself is being viewed (at /form/my-form). I've tried when Content is viewed of type Webform, didn't work either.

Is it possible? Or maybe the condition based on the form_id.

πŸ’¬ Support request
Status

Fixed

Component

Rules Core

Created by

πŸ‡¬πŸ‡§United Kingdom kenorb

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

Comments & Activities

  • Issue created by @kenorb
  • πŸ‡¬πŸ‡§United Kingdom kenorb
  • Status changed to Fixed almost 2 years ago
  • πŸ‡ΊπŸ‡ΈUnited States tr Cascadia

    "Webform is viewed" is a specific version of "Entity is viewed", which is triggered by the core Drupal hook_entity_view().

    See https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21... for an explanation of the entity lifecycle in Drupal.

    The critical thing to understand with this hook/event is that it is only triggered when the entity is rendered for display. When the entity is loaded from the cache (which it almost ALWAYS is ...), it DOESN'T get rendered again so hook_entity_view() hook will not be called and the "Webform is viewed" event will not be generated. This is fundamental to how Drupal core and Drupal caching works.

    If what you want to do is have a Rule triggered whenever a specific page is visited, then "Webform is viewed" is not the correct event to use for this reason, AND because an entity like a Webform can appear not only on its own page (/node/12 for example) but can also appear on many other pages (plain /node for example) so viewing the entity is NOT a guarantee that you're on the page you think you're on.

    Instead, use the "Drupal is initializing" event, which is triggered on every page load, then use a path comparison condition such as "Path contains text" or "Path text comparison" to determine if you're on the correct page before executing your action.

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

Production build 0.71.5 2024