Problem/Motivation

I'm seeing extra-long template suggestions with repeated suggestions in the template name, e.g. input--submit--node-article-delete-form--op--node-article-delete-form--op.html.twig.

It looks like the pre-render function is being run more than once.

This happens when Drupal goes to render a form that has a #theme hook. I've confirmed this scenario with xdebug:

  1. Drupal starts to render the form.
  2. Drupal does the pre-render phase and calls Dazzler::preRenderForm().
  3. Drupal sees the #theme hook for the form, it passes the $form as a variable to the form template.
  4. The form template goes to render the form variable and re-starts Drupal rendering.
  5. Bam. Drupal does the pre-render phase again and calls Dazzler::preRenderForm().

This is a core bug, but we can prevent this problem inside Dazzler::preRenderForm().

Steps to reproduce

The node delete form shows this problem.

Proposed resolution

Prevent pre-render function from altering the form multiple times.

Issue fork formdazzle-3182297

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

JohnAlbin created an issue. See original summary.

johnalbin’s picture

Title: Duplicate, extra-long template suggestions » Prevent redundant, extra-long template suggestions
Issue summary: View changes
Status: Active » Needs review

  • JohnAlbin committed f26e02c on 2.x
    Issue #3182297 by JohnAlbin: Prevent redundant, extra-long template...
johnalbin’s picture

Assigned: johnalbin » Unassigned
Issue summary: View changes
Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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