The submit button is not following any condition while in popup/dialogs

Created on 21 October 2018, about 7 years ago
Updated 24 August 2023, over 2 years ago

Hi,

Description of the issue
The form button like the default "Submit" button of any webform , is not accepting any #state conditions once the dialog is initialized.

Problem
The problem is in getting the default state of the button to initialize in the dialog. Because once you start entering input values the button's state is updated.

Why
The issue is Drupal.behaviors.dialog.prepareDialogButtons in core/misc/dialog/dialog.ajax.es6.js clones the primary buttons without copying the #states conditions.

This must be a core States API issue.

Reproduce the issue:

1) Install the webform module.

2) Using the built-in "contact" form, create a condition to hide the "Send message" button.

_ "Hidden" if "Your Name" textfield value is "Hide Button".

the yaml #state condition will be something like:

  '#states':
    invisible:
      ':input[name="name"]':
        value: 'Hide Button'

3) Add the "contact" form as a field of type "webform" to the article content type.

4) Create one test article, lets consider the article nid is "12".

5) launch the created article in a dialog/popup using the below code:

<a class="use-ajax" data-dialog-type="modal" href="/node/12">Open article</a>

6) Find the webform field and try to input inside the "your name" field the text: Hide Button

7) You will notice that the "Send message" button is still visible without any changes for its #states.

Reference
The discussion of the webform issue here , lead to create this core issue.

Thank you all for your help and time,

Below is the source code of a configured "contact" form to speed up the reproducing of the issue:

name:
  '#type': textfield
  '#title': 'Your Name'
  '#required': true
  '#default_value': '[current-user:account-name]'
  '#multiple__no_items_message': '<p>No items entered. Please add items below.</p>'
email:
  '#title': 'Your Email'
  '#type': email
  '#required': true
  '#default_value': '[current-user:mail]'
subject:
  '#type': textfield
  '#title': Subject
  '#required': true
  '#states':
    visible:
      ':input[name="name"]':
        value: Webform
  '#multiple__no_items_message': '<p>No items entered. Please add items below.</p>'
  '#test': 'Testing contact webform from [site:name]'
message:
  '#title': Message
  '#type': textarea
  '#required': true
  '#test': 'Please ignore this email.'
actions:
  '#type': webform_actions
  '#title': 'Submit button(s)'
  '#states':
    invisible:
      ':input[name="name"]':
        value: 'Hide Button'
  '#states_clear': false
  '#submit__label': 'Send message'
🐛 Bug report
Status

Needs review

Version

11.0 🔥

Component
Ajax 

Last updated 5 months ago

Created by

🇱🇧Lebanon C.E.A

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • last update over 2 years ago
    Custom Commands Failed
  • 🇩🇪Germany hchonov 🇪🇺🇩🇪🇧🇬

    Re-roll for 10.1.x

  • last update over 2 years ago
    Custom Commands Failed
  • last update over 2 years ago
    30,058 pass
  • 🇮🇳India gauravvvv Delhi, India

    I have fixed the failures also attached interdiff for same. please review

  • 🇮🇳India gauravvvv Delhi, India
  • Status changed to Needs work over 2 years ago
  • 🇺🇸United States smustgrave

    The IS appears to be missing the proposed solution.

    Also should add a test case showing the issue.

  • 🇭🇺Hungary huzooka Hungary 🇭🇺🇪🇺

    Sharing my very naive alternative patch (on top of 10.2.x), maybe this can help some of you.

  • Merge request !13733Resolve #3008172 "Submit button" → (Open) created by claudiu.cristea
  • Pipeline finished with Failed
    about 1 month ago
    #690071
  • Pipeline finished with Failed
    about 1 month ago
    Total: 958s
    #690292
  • Pipeline finished with Success
    about 1 month ago
    Total: 581s
    #690316
  • Pipeline finished with Canceled
    12 days ago
    Total: 148s
    #703229
  • Pipeline finished with Failed
    12 days ago
    Total: 635s
    #703231
  • Pipeline finished with Canceled
    12 days ago
    Total: 139s
    #703497
  • Pipeline finished with Failed
    12 days ago
    Total: 755s
    #703498
  • Pipeline finished with Failed
    11 days ago
    Total: 234s
    #703845
  • Pipeline finished with Success
    11 days ago
    Total: 1077s
    #703853
  • Pipeline finished with Failed
    7 days ago
    Total: 276s
    #708620
  • Pipeline finished with Success
    7 days ago
    Total: 945s
    #708637
  • Pipeline finished with Success
    7 days ago
    Total: 466s
    #708649
  • Pipeline finished with Success
    5 days ago
    Total: 642s
    #710291
  • Pipeline finished with Success
    5 days ago
    Total: 419s
    #710698
Production build 0.71.5 2024