Problem
There is currently no standard (and easy) way in Drupal's Form API to allow for a user friendly form submission confirmation step.

We have ConfirmFormBase which can be used as a separate form for a single action, this is not fit for a multi-step flow in which you first want to gather input from the user. And it is especially not straightforward to ask for extra (to be validated) input during a confirmation step.

Exemplary is the current edit account page. In this case the Edit action and Confirm action are put together on the same page. Several usability studies, including the issue below, show that this pattern is confusing to users.
https://www.drupal.org/node/1259892
But also the new Content Layout functionality could benefit from this new option.

Solution

Introduce a confirmation modal, which optionally allows for extra user input that can be validated.

This allows for easily separating two dedicated user interaction steps from each other. So users only need to deal with one step at a time, and by using a modal the urgency is more clear and allows for a more fluid interaction.

By providing a standardized solution to this problem contrib can also create better forms.

Example

Please see how it can work in the following prototype.
This prototype uses the Edit Account page as an example. When submitting changed field(s) that require the current password to apply, show a modal window asking the user to confirm the changes by entering the current password.

http://prototype.goalgorilla.com/drupalux/currentpassword/#g=1&p=edit_ac...

API changes

We would need some new properties/methods to the Form API that allow to:
- Set that a form submission confirmation is always needed OR set a list of fields that need confirmation on change
- Give a custom confirmation form (class), which defaults to a default confirmation form like ConfirmFormBase.

Other examples
This design pattern is also widely used by other services.

Mailchimp:

Hubspot:

CommentFileSizeAuthor
#6 hubspot_modal.png48.82 KBdmsmidt
#4 mailchimp_modal.png28.79 KBxinyuma
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

xinyuma created an issue. See original summary.

xinyuma’s picture

Issue summary: View changes
cilefen’s picture

Version: 8.3.2 » 8.4.x-dev
Priority: Critical » Major
Status: Needs review » Active

This does not meet the criteria for a critical bug.

xinyuma’s picture

Title: Make current password field easier to notice » Separate modify action from confirmation action to avoid confusion
Issue summary: View changes
FileSize
28.79 KB
dmsmidt’s picture

Title: Separate modify action from confirmation action to avoid confusion » Introduce a submit confirmation step modal to Form API for usability
Component: user.module » forms system
Issue summary: View changes
Issue tags: +Usability, +FAPI
Related issues: +#2254935: Use a modal for content entity form delete links confirmation forms, +#2253257: Use a modal for entity delete operation links

I really like the mock-up and the potential usability improvements for confirm steps of any form. This is especially true for the edit user form where the user needs to enter his current password.

This design pattern is a proven concept (see Mailchimp screenshot).

I found two related issues about using modals for a confirm step:
#2253257: Use a modal for entity delete operation links
#2254935: Use a modal for content entity form delete links confirmation forms

Also people are asking for this feature on StackExchange.

(Elaborated the IS after our Slack discussion)

dmsmidt’s picture

Issue summary: View changes
FileSize
48.82 KB

Found another example by Hubspot.

yoroy’s picture

Here's another potential use case in core: https://www.drupal.org/node/2880374#comment-12152034
A situation where we might want to use an extra "are you really really sure" confirmation step.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

cgomezg’s picture

There is any progress here?

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

ultrabob’s picture

The arguments for this being useful in core are very good, and I found this issue when looking for the best solution for my custom module, so it is definitely useful outside of core as well. Is there some process this needs to go through or does someone just need to start working on it and submitting patches?

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

idiaz.roncero’s picture

+1, I came across this need for a project and it is too cumbersome to add a confirmation form.

In my case, the client sells "resources" (entity publication, amongst others) and those resources can be "consumed" on workflow state changes (i.e. when they "activate" an entity, the resource gets consumed, and this is costly for the user since "activation" is the scarcest resource).

We want to prompt the user for a confirmation in order to make it clear whenever their changes mean a resource will be consumed.

I think this is a common scenario and Drupal could provide for a simple way to "attach" a confirmation form or modal (i prefer forms because modals will introduce a Javascript dependency)

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

AaronMcHale’s picture

This could be useful for user login, logout and password reset.

It could also be useful for the Entity API in deleting an Entity, the delete confirmation form would work well in a modal.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

david.qdoscc’s picture

I agree it would be nice to have this sitting between validateForm and submitForm

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Feuerwagen’s picture

Category: Bug report » Feature request
Priority: Major » Normal
Issue tags: +Bug Smash Initiative

This maybe started as kind of a bug report, but apparently turned into a feature request shortly afterwards.

Btw: Looks useful to me as well. ;)

Tregonia’s picture

+1 for this being a potentially nice addition to core.

In my use-case, when a user is changed from Active to Blocked, several custom things are triggered. Having the ability to define a confirmation step between validation and submit would be a welcome addition, and better encapsulate all the form functionality.

maskedjellybean’s picture

I've love to see a solution for this.

I mistakenly thought I could solve this using ConfirmFormBase (https://www.drupal.org/docs/drupal-apis/form-api/confirmformbase-to-conf...), but I've come to the disappointing conclusion that it's simply not feasible to add confirmation to an existing form that does not already extend ConfirmFormBase. In order to add this to an existing form you would first need to override the existing form class with a new class that you control. This is possible. However, in order to avoid duplicating all of the code from the existing class, you would want to extend that class and only modify the necessary methods while calling the parent methods inside your modified methods when possible. But then of course your new class does not extend ConfirmFormBase, so you are right back where you started.