Entity form steps are also applied to the delete form

Created on 15 August 2023, over 1 year ago
Updated 16 August 2023, over 1 year ago

Problem/Motivation

When an entity is split into multiple form steps using the Entity Form Steps field groups, these form steps are also applied to the entity's delete form.

Proposed resolution

Do not apply Entity Form Steps to the entity's delete form.

Remaining tasks

  1. Write a patch
  2. Review
  3. Commit

User interface changes

Entity form steps are no longer applied to the delete form

API changes

None.

Data model changes

None.

πŸ“Œ Task
Status

Fixed

Version

1.1

Component

Code

Created by

πŸ‡³πŸ‡±Netherlands idebr

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

Comments & Activities

  • Issue created by @idebr
  • Status changed to Postponed: needs info over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States robphillips

    Please add specific steps to replicate. Tried on the default article (node) content type to no avail. Furthermore, the code is always using the current form display to get the applicable steps (see https://git.drupalcode.org/project/entity_form_steps/-/blob/1.x/src/Form...). Most entity delete forms, such as NodeDeleteForm, are derived from ContentEntityConfirmFormBase which isn't using form display modes.

  • πŸ‡§πŸ‡ͺBelgium chewi3

    I haven't tested from a clean Drupal install, but the way it is currently set up does seems like a possible problem.

    The entity_form_steps_form_alter hook checks if the form object is an instance of ContentEntityFormInterface. ContentEntityConfirmFormBase extends ContentEntityForm, so the node delete form is also altered.

    Usually you only have the "default" form display mode. So if this is the form mode that has the step field groups, they will also be retrieved for the delete form (since it tries to look for a "delete" form mode, but defaults to the "default" form mode.

    I did fix our problem by adding an extra content form mode next to the default. By adding an "edit" form mode with the steps and removing the steps from the default, the issue is fixed.

    Not sure what a good fix would be, if it is even needed. I did add a patch with a possible solution (checking the form state operation and only altering the form when in 'edit mode'), so feel free to review if something like this could be helpful to add.

  • πŸ‡§πŸ‡ͺBelgium chewi3

    In my previous comment I forgot to account for node creation (which seems to correspond to the "default" operation). Which also means my fix needs to be slightly adjusted (I guess I can specifically add a "delete" content form mode instead and do it the other way around).

    Adding an updated patch.

    • Chewi3 β†’ authored 2570d832 on 1.x
      Issue #3381191 by Chewi3: Entity form steps are also applied to the...
  • Status changed to Fixed over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States robphillips

    Thanks! Didn't initially realize the entity delete form ultimately extends the base entity form. Opted to target the delete operation because module builders have the option to define additional operation types. And moved the conditional into EntityFormSteps.php.

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

Production build 0.71.5 2024