Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Instead of on form submit validation triggering on "add another item" of multivalue field collection item.
Setup
Field Collection item
-------Item --Entityreference Field
-------Specs -- Textfield
configuration: multivalue, unlimited
validation applied:Number of selections on field collection item with min 3 and max to 10.
When selecting first ER field and filling specs textfield when "add another item" is clicked then configured error message is showing.
Comment | File | Size | Author |
---|---|---|---|
#5 | issue_2291675-limit-required-to-one.patch | 1.06 KB | sassafrass |
Comments
Comment #1
g089h515r806 CreditAttribution: g089h515r806 commented"add another item" , means http request by ajax,
Comment #2
firfin CreditAttribution: firfin as a volunteer and commentedUnfortunately this makes this module (or at least the 'Number of selections' validator) unusable with field collection. There is no way to reach the minimum number of values because the validation stops the adding of items. A shame really, I have seen many issues calling for a minimum ( or maximum or range) number of values.
Comment #3
joelpittetSame problem as #2 describes.
Comment #4
sassafrass CreditAttribution: sassafrass as a volunteer commentedI have a required field where the user can (add another) an "unlimited" number of times. Upon creation of the entity, this works as expected. However, each time the entity is edited, validation "requires" me to enter another value even if one already exists.
Comment #5
sassafrass CreditAttribution: sassafrass as a volunteer commentedI have added a patch that limits "Required" to the first of a field with multiple or unlimited cardinality. Please review and let me know if it works for your use case(s).