The core/drupal.form library is not added to all drupal forms.

  1. Add core/drupal.form library to all Drupal forms.
  2. Create a new library in the user module and a new user.register.js file where the code of Drupal.behaviors.fillUserInfoFromBrowser will be moved and add this new user library to the registration form.

Original report

There is a problem with form submission if you quickly double click the form.

Steps to reproduce:
1. Download and install the Drupal core
2. Go to /admin/structure/types/manage/article/fields/add-field
3. Select any type of field (lets pick Boolean)
4. Type the title "Test"
5. Double click the "Save and Continue"

Result:
It will be presented with "The machine-readable name is already in use. It must be unique."

The field of "field_test" was created successfully but unable to continue the process because of the double posting to the server, it causes the whole thing break.

Files: 
CommentFileSizeAuthor
#17 add_core_drupal_form-2395845-17.patch5.65 KBk4v
FAILED: [[SimpleTest]]: [PHP 5.4 MySQL] 86,181 pass(es), 6 fail(s), and 0 exception(s). View
#14 add_core_drupal_form-2395845-14.patch5.71 KBk4v
FAILED: [[SimpleTest]]: [PHP 5.4 MySQL] 86,149 pass(es), 6 fail(s), and 0 exception(s). View

Comments

Rajeev H’s picture

Status: Active » Needs review
Issue tags: +#SprintWeekend2015
FileSize
674 bytes
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 82,538 pass(es). View

When user clicks on The submit button the button will be hidden with, please wait.. message

FreekyMage’s picture

I'm not sure this is the way to do this, but here is some general code feedback on the ticket:

  • The text should be translatable, from ajax.js : Drupal.t('Please wait...')
  • The second $('#field-ui-field-storage-add-form #edit-submit') can be replaced with $(this)
  • Indenting on the code could be better
nod_’s picture

Version: 8.0.0-beta4 » 8.0.x-dev
Issue tags: +JavaScript

This is supposed to be fixed by #1705618: Double click prevention on form submission. Which browser and version are you using?

I'd rather avoid going down the path #1 is going. We really don't want to be handling form state if we can avoid it.

Can someone check on firefox whether the same bug appears or not?

nod_’s picture

Status: Needs review » Needs work
FreekyMage’s picture

Tested in Firefox, no problem there. IE (11) has the problem, just like Chrome (39).

YesCT’s picture

Issue tags: -#SprintWeekend2015 +SprintWeekend2015

Thank you for working on this issue.

We should all try and use the same sprint tag. According to https://groups.drupal.org/node/447258 it should be SprintWeekend2015 with no #.

Rajeev H’s picture

Version: 8.0.x-dev » 8.0.0-beta4
Category: Bug report » Task
Status: Needs work » Needs review
Issue tags: -SprintWeekend2015, -JavaScript +#SprintWeekend2015
FileSize
673 bytes
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 82,545 pass(es). View

When user clicks on The submit button the button will be hidden with replacing text as- please wait..

alimac’s picture

Issue tags: -#SprintWeekend2015 +SprintWeekend2015

@rajeev.rymec Thanks for posting the patch. We should all try and use the same sprint tag. According to https://groups.drupal.org/node/447258 it should be SprintWeekend2015 with no #.

YesCT’s picture

Version: 8.0.0-beta4 » 8.0.x-dev
Issue summary: View changes

@rajeev.rymec Thank you for trying to help with this issue.

We work against dev versions, not tagged milestones like betas.
If the code base has changed since beta 4, you may have to reroll the patch. But this applies fine to head.

Actually... the patch in #1 still applies to head. Why upload a new patch that is exactly the same?

Why change this from a bug to a task?
See https://www.drupal.org/core/issue-category for definition of issue category values: Bug, Task, Feature request, Support request.

Rajeev H’s picture

Category: Task » Bug report

@all Thanks for your suggestions, there is some change in patch 2

nod_’s picture

Status: Needs review » Needs work

Thanks for the patch but what we need is to look into why Drupal.behaviors.formSingleSubmit is not doing it's job when there is a double click, not adding more code.

This piece of code was supposed to replicate Firefox behavior of not submitting a form several times if the form values haven't changed. See https://github.com/sun/jquery-form-submit-single for more detailed explanations of what we're going for and please read especially the pharagraph called On not manipulating the user interface.

The patch submitted is suited for a on-off project, it is not suited for Drupal core. It is to specific and makes many assumptions Drupal core can't afford to make.

nod_’s picture

Title: Double click on creating new field » Add core/drupal.form library to all Drupal forms
Issue summary: View changes
Issue tags: +JavaScript

Just checked, form.js is not added to the page, that is the problem.

What needs to be done is to move Drupal.behaviors.fillUserInfoFromBrowserout of form.js and in a new js file in the user module (called user.register.js or something) and add it to the registration form. Then make sure core/drupal.form library is added to all drupal forms so that we have the Drupal event for updated values as well as double submit protection.

k4v’s picture

Assigned: Unassigned » k4v
k4v’s picture

FileSize
5.71 KB
FAILED: [[SimpleTest]]: [PHP 5.4 MySQL] 86,149 pass(es), 6 fail(s), and 0 exception(s). View

This is a first try, not sure if I got the right spot to add drupal.form globally.

k4v’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 14: add_core_drupal_form-2395845-14.patch, failed testing.

k4v’s picture

FileSize
5.65 KB
FAILED: [[SimpleTest]]: [PHP 5.4 MySQL] 86,181 pass(es), 6 fail(s), and 0 exception(s). View

Minor changes nitpicked by @tstoeckler =)

Wim Leers’s picture

Then make sure core/drupal.form library is added to all drupal forms so that we have the Drupal event for updated values as well as double submit protection.

UGH. -1

This will cause JS to be loaded on pretty much every page, because e.g. the search form is going to be on almost every page. Isn't there any other way?

First thought: only do this if we know it's going to submit actual data. E.g. SearchBlockForm sets $form['#method'] = 'get';. And it doesn't set any #submit handler. In other words: find a clever enough heuristic to only then add this form.

Second thought: can we avoid doing this for anonymous users?

Third thought: cookie with the form ID + form build ID that's just been submitted, so we can detect it on a resubmit?

tstoeckler’s picture

Status: Needs work » Needs review

Interesting thoughts. Let's send this to the testbot in the meantime.

Status: Needs review » Needs work

The last submitted patch, 17: add_core_drupal_form-2395845-17.patch, failed testing.

k4v’s picture

Assigned: k4v » Unassigned

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.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.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.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.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.