Problem/Motivation

Steps to reproduce

  • Create a webform and add a textfield element (say Fruit Name)
  • Add a another element of type tableselect. (say Fruit Category) with options (say 1 => Summer, 2 => Spring, 3 => Winter)
  • Make the Fruit Category field mandatory
  • Add conditional states to make the Fruit category field visible only when the Fruit Name is filled
  • Now go to the web form, and add a submission.
  • Fill the First Name field (say Benedict Joseph)
  • Now the Fruit Category field will be visible. For Fruit Category select the second and /or third option (Spring or Winter) without selecting the first option.
  • The form submission fails unless we add the first option

Proposed resolution

As a temporary work around we used checkboxes type instead of tableselect type

Remaining tasks

Patch
Review
Commit

User interface changes

API changes

Data model changes

Issue fork webform-3309335

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

MaryJewel created an issue. See original summary.

jomsy’s picture

Issue summary: View changes
jomsy’s picture

Issue summary: View changes
cilefen’s picture

Version: 6.1.3 » 6.1.x-dev
Status: Active » Postponed (maintainer needs more info)
Issue tags: -webform, -tableselect element

Please provide a minimal form that demonstrates the bug.

jomsy’s picture

@cilefen
Please find the Webform source below:

fruit_name:
  '#type': textfield
  '#title': 'Fruit Name'
fruit_category:
  '#type': tableselect
  '#title': 'Fruit Category'
  '#options':
    1: Summer
    2: Spring
    3: Winter
  '#states':
    visible:
      ':input[name="fruit_name"]':
        filled: true
  '#required': true
cilefen’s picture

Status: Postponed (maintainer needs more info) » Active

If I am understanding this report correctly, isn't this just the Drupal Core Form API's ordinary behavior, which is that required fields are simply required, whether or not JavaScript has hidden them?

jomsy’s picture

@cilefen
The issue is not that the hidden field is required.

The Fruit Category field, when it is visible(i.e the First Name field is filled) ,always forces the user to select the option Summer for submitting the form. You can't just select the Spring option and submit the webform

jomsy’s picture

Issue summary: View changes
cilefen’s picture

Title: Webform | Issue while adding conditional states to a tableselect element » Only the first tableselect element option “counts” for conditional states
Issue summary: View changes

I’ve added a descriptive title based on what I understand about what you are saying.

In the steps to reproduce, can you explain in more detail what about the form post fails and in what way?

jrockowitz’s picture

Version: 6.1.x-dev » 6.2.x-dev
StatusFileSize
new5.08 KB

The attached webform replicates the issue.

jrockowitz’s picture

Status: Active » Needs review

The MR is very safe and minor tweak to fix the conditional logic.

jrockowitz’s picture

Status: Needs review » Reviewed & tested by the community

Marking RTBC with assumption that all the tests will pass.

  • jrockowitz committed 7edb7c57 on 6.2.x
    Issue #3309335: Only the first tableselect element option “counts” for...
jrockowitz’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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