Problem/Motivation

I picked up an issue on a client's website during development. After adding a couple of webforms to the site, I noticed that the confirmation modal did not work for all but one of the forms.

All of the affected forms were being overridden by custom webform-submission-form--[form-name].html.twig templates, where the {{ form }} token was commented out and individual fields were rendered in a custom layout instead.

My first thought was that I must be missing a token related to the confirmation message, but I searched far and wide, debugged the form array, but no luck.

Either there is something very clearly missed and I cannot see, or this is a bona fide bug and needs an extra pair of eyes on it.

Below is a step-by-step guide to reproduce the issue.

Steps to reproduce

1) Install latest Drupal (composer create-project drupal/recommended-project:10.1.6 "install-dir")

2) Install Bootstrap Barrio 5 Theme (composer require 'drupal/bootstrap_barrio:^5.5')

3) Enable Bootstrap Barrio 5 Theme and enable and set the Bootstrap Barrio Subtheme as default

4) Install Webform (composer require 'drupal/webform:^6.2')

5) Enable Webform and Webform UI

6) Navigate to /admin/structure/webform and edit the default contact form that ships with webform and do the following:
a) Go to Settings > General and tick the Use Ajax checkbox and click save
b) Go to Settings > Confirmation and select Modal as the confirmation type and click save

7) Navigate to /web/modules/contrib/webform/templates and copy webform-submission-form.html.twig

8) Navigate to /web/themes/contrib/bootstrap_barrio/subtheme/templates and paste webform-submission-form.html.twig

9) Rename webform-submission.html.twig to webform-submission-form--contact.html.twig

10) Edit webform-submission-form--contact.html.twig and do the following:
a) Comment out {{ form }}
b) Add the following code and save the file:

<div class="row">
    <div class="col-md-6">
        {{ form.elements.name }}
    </div>
    <div class="col-md-6">
        {{ form.elements.email }}
    </div>
</div>

<div class="row">
    <div class="col-md-6">
        {{  form.elements.subject }}
    </div>
    <div class="col-md-6">
        {{  form.elements.message }}
    </div>
</div>

{{ form.elements.actions }}
{{ form.form_build_id }}
{{ form.form_token }}
{{ form.form_id }}

11) Flush cache

12) Navigate to /webform/contact/test in the browser and click the submit button

13) The confirmation modal will fail to display

14) Navigate to /web/themes/contrib/bootstrap_barrio/subtheme/templates and edit webform-submission-form--contact.html.twig with the following:
a) Uncomment {{ form }} and comment out everything we added in step 10b above. Save the file

15) Flush cache

16) Navigate to /webform/contact/test in the browser and click the submit button once again

17) The confirmation modal works

Comments

Journosergio created an issue. See original summary.

journosergio’s picture

Issue summary: View changes
journosergio’s picture

Issue summary: View changes
cilefen’s picture

Category: Bug report » Support request

Are there console errors?

cilefen’s picture

Title: Confirmation Modal Fails to Display on Form Submission » Confirmation Modal Fails to Display on Form Submission With this Custom Template
journosergio’s picture

Hi there,

Nope, no console errors and no errors in the logs either.

cilefen’s picture

What is the diff between the default webform-submission.html.twig and webform-submission-form--contact.html.twig?

journosergio’s picture

Diff as follows: https://www.diffchecker.com/c1mHjupv/ (The former is the default)

cilefen’s picture

It looks like you are missing the form tag and some attributes. Is the HTML valid?

Perhaps https://drupal.stackexchange.com/questions/232980/how-to-access-webform-...

journosergio’s picture

Issue summary: View changes

The form tag won't be there otherwise the form will be rendered twice. Once through the form tag, and again through the individual form elements.

As far as I know, and have seen, all necessary elements are present and the modal should work.

In terms of the HTML, it is valid yeah. There was a missing bracket on the last closing div but that is not cause for concern.

cilefen’s picture

Status: Active » Postponed (maintainer needs more info)

Is there an update on this?

jrockowitz’s picture

The Webform module's issue queue is for bugs, feature requests, and planning. Please post general support questions to Drupal Answers. You can also ask questions or help answer questions on the #webform channel on Drupal Slack.

It is very challenging to override the default rendering of a webform. I recommend not doing it.

jrockowitz’s picture

Version: 6.2.0 » 6.2.x-dev
jrockowitz’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)
mukhtarm’s picture

hi @jrockowitz Can you please check if this issue is related?

https://drupal.stackexchange.com/questions/320938/webform-confirmation-p...