Problem/Motivation

I have a multiple value element - textfield added to my webform. The Advance Properties for the Multiple Settings are set as below:
- Minimum amount of items = 0 (I do not want it to be required)
- Number of empty items = 0 (I do not want it to appear on the form when the form loads)
- Number of add more items = 1 (default)

On the form load, the textfield does not appear (which is what I want), and Add button adds the textbox to accept the value. But when there are no values entered and no textbox is added using the "Add" button, the webform displays the blank textfield after returning from server-side error ($form_state->setErrorByName()).

Technically the multiple value textfield should not show up as it was never added in the first place.

Steps to reproduce

  1. Create a webform
  2. Add Element -> Text field
  3. Provide appropriate name and set the "Allowed number of values" to Unlimited (ex machine name = text_multiple)
  4. Go to Advanced -> Multiple Settings
  5. Set Minimum amount of items = 0,
  6. Set Number of empty items = 0
  7. Number of add more items = 1
  8. Add another Text field with all default settings. (ex machine name = text_regular)
  9. Go to the form and fill out text_regular textbox and not adding the text_multiple (it should be hidden by default until you add manually by the "Add" button)
  10. Submit the form. However, you'll have to create a temporary module that can throw an error for you, or produce the error as you prefer
  11. After the error, the form will load the text_regular with your initial provided value, as well the the new blank text_regular - which was never added and was never provided with any value.

Comments

sgohil1 created an issue. See original summary.

sgohil1’s picture

Issue summary: View changes
jrockowitz’s picture

StatusFileSize
new4.15 KB

The attached webform can be used to replicate this issue.

jrockowitz’s picture

Priority: Critical » Normal
Status: Active » Needs review
StatusFileSize
new391 bytes

You have to love one-line patches.

  • jrockowitz committed 8d9e2a5 on 8.x-5.x
    Issue #3009648 by jrockowitz: Multiple value element shows up after...
jrockowitz’s picture

Status: Needs review » Fixed

I committed the patch. Please download the latest dev release to review.

sgohil1’s picture

@jrockowitz
Indeed I love the one-line patches. Thanks a lot, it totally fixed the problem.

Again, thanks a bunch for the super quick fix.

Status: Fixed » Closed (fixed)

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