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
- Create a webform
- Add Element -> Text field
- Provide appropriate name and set the "Allowed number of values" to Unlimited (ex machine name = text_multiple)
- Go to Advanced -> Multiple Settings
- Set Minimum amount of items = 0,
- Set Number of empty items = 0
- Number of add more items = 1
- Add another Text field with all default settings. (ex machine name = text_regular)
- 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)
- 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
- 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.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 3009648-3.patch | 391 bytes | jrockowitz |
| #3 | webform.webform.issue_3009648.yml | 4.15 KB | jrockowitz |
Comments
Comment #2
sgohil1 commentedComment #3
jrockowitz commentedThe attached webform can be used to replicate this issue.
Comment #4
jrockowitz commentedYou have to love one-line patches.
Comment #6
jrockowitz commentedI committed the patch. Please download the latest dev release to review.
Comment #7
sgohil1 commented@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.