Fields with unlimited cardinality show 1 extra input field

Created on 20 June 2018, over 6 years ago
Updated 21 August 2024, 4 months ago

If a field has unlimited cardinality, then it is always displayed with one input too many. For example, I added a textfield named "Labels" to a content type and gave it unlimited cardinality. I create three label values, as illustrated here:

Then I Save the form and go to Edit it again. When I do, one extra Label input has been added, even though I have not clicked the "Add another item" button. And there's no way to get rid of this extra input field:

Always adding an unused text field gives users the impression that the form was not completely filled out even when it was, or that they clicked the "Add another" button when they did not.

I tracked the source of the "bug" down to a single line in the WidgetBase class. It looks like an off-by-one error to me, with respect to the difference between how the number of elements is calculated for a fixed, multiple cardinality field vs. how the number of elements is calculated for an unlimited cardinality field.

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
Field 

Last updated 1 day ago

Created by

🇺🇸United States lisastreeter

Live updates comments and jobs are added and updated live.
  • Needs change record

    A change record needs to be drafted before an issue is committed. Note: Change records used to be called change notifications.

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.

Production build 0.71.5 2024