Problem/Motivation
Possibly a feature request instead of a bug report. We are encountering the following scenario:
- Add a composite element.
- Mark an individual field inside it required.
- Limit to 3 allowed values.
The user is required to fill all three rows, instead of up to three rows.
Screenshot and sample webform:

test_composite:
'#type': custom_composite
'#title': 'Test Composite'
'#required': true
'#multiple': 3
'#element':
foo:
'#type': textfield
'#title': 'Foo (required)'
'#required': true
bar:
'#type': textfield
'#title': 'Bar (optional)'
Proposed resolution
There could be a few ways to address this. Some possible solutions:
- Fields are only validated as required for rows in a composite that are not empty.
- The "Limit" setting could work the same as "Unlimited", but the "Add another" button is hidden once the limit is reached.
Comments
Comment #2
jrockowitz commentedPersonally, I use the limit to show all the available rows so that the user does not have to keep clicking 'Add more'.
I like...
Comment #3
vierlexThere should be both options I guess.
But I personally would use only the second option.
Since in case for composites (lets say, 7 fields) which you want to have, say, 10 maximum,
Displaying all 10x7 is way too much.
Comment #4
jrockowitz commentedThe attached patch stops defaulting the displayed number of items to match the cardinality.
If someone wants the displayed number of items to match the cardinality they can set the #min_items.
Comment #5
jrockowitz commentedComment #7
jrockowitz commentedComment #9
vierlexWow so cool! I will test it right away
Comment #10
jrockowitz commentedComment #11
jrockowitz commentedThis patch makes sure min items and empty item don't exceed the cardinality.
Comment #13
jrockowitz commentedI committed the patch. Please download the latest dev release to review.
Here is the change record.