form_alter runs on Confirm Forms and causes AJAX errors

Created on 12 February 2025, 3 months ago

Problem/Motivation

When using Content Lock with e.g. the Trash module, an AJAX error appears on certain Confirm Forms:

The "entity" parameter was not converted for the path "/admin/lock/create/node/{entity}/{langcode}/{form_op}" (route name: "content_lock.create_lock.node")

I think this is not an issue of the mentioned Trash module, but has to do with when the "drupal.content_lock.lock_form" library is applied inside the form_alter hook.

Steps to reproduce

  1. Install Content Lock and the Trash module https://www.drupal.org/project/trash .
  2. Move a node to the trash.
  3. Restore the node.
  4. The error appears on the confirm form.

Proposed resolution

I've included a patch file with a solution: A check that the current form is NOT of ConfirmFormInterface. This works for my use-case right now, but I think a better solution would be to more clearly define what exact forms should be altered in the hook.

🐛 Bug report
Status

Active

Version

3.0

Component

Code

Created by

🇳🇱Netherlands perryjanssen

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024