Unless I'm missing an option somewhere in the configuration, there doesn't appear to be an option to limit the number of allowed values for a field. I have the requirement to allow users upload multiple files to one field in a form, but limit it to no more than 3. I can't see an option for that - I can either have the "multiple" checkbox unchecked which limits it to just 1 entry, or have "multiple" checked, in which case there doesn't seem to be a limit.

Would there be any way to add this functionality? Thanks

Comments

stella created an issue. See original summary.

jrockowitz’s picture

Right now, #multiple only support TRUE (1) = UNLIMITED VALUES or FALSE (0) => ONE VALUE.

At some point I want to extend #multiple to support limits (ie > 1). It would required updates to the webform element UI and a new validation handler.

It is a medium amount of work and is now on the immediate roadmap.

  • jrockowitz committed a60f15a on 2854879-multiple-limit
    Issue #2854879: Ability to limit the number of allowed values
    

  • jrockowitz committed 0242f6f on 2854879-multiple-limit
    Issue #2854879: Ability to limit the number of allowed values
    
jrockowitz’s picture

Status: Active » Needs review
StatusFileSize
new26.85 KB
new239.76 KB

I need to see if this patch breaks anything and then I will write some tests.

Below is a preview of the change.

  • jrockowitz committed 4ab0243 on 2854879-multiple-limit
    Issue #2854879: Ability to limit the number of allowed values
    
  • jrockowitz committed 9054094 on 2854879-multiple-limit
    Issue #2854879: Ability to limit the number of allowed values
    
jrockowitz’s picture

StatusFileSize
new28.94 KB

  • jrockowitz committed 53d42d2 on 2854879-multiple-limit
    Issue #2854879: Ability to limit the number of allowed values
    

The last submitted patch, 5: ability_to_limit_the-2854879-5.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 7: ability_to_limit_the-2854879-7.patch, failed testing.

  • jrockowitz committed 93bbab6 on 2854879-multiple-limit
    Issue #2854879: Ability to limit the number of allowed values
    
jrockowitz’s picture

Status: Needs work » Needs review
StatusFileSize
new33.7 KB

Status: Needs review » Needs work

The last submitted patch, 12: ability_to_limit_the-2854879-11.patch, failed testing.

  • jrockowitz committed b16e0e8 on 2854879-multiple-limit
    Issue #2854879: Ability to limit the number of allowed values
    
jrockowitz’s picture

Status: Needs work » Needs review
StatusFileSize
new34.77 KB

Status: Needs review » Needs work

The last submitted patch, 15: ability_to_limit_the-2854879-15.patch, failed testing.

  • jrockowitz committed a0a68ce on 2854879-multiple-limit
    Issue #2854879: Ability to limit the number of allowed values
    
jrockowitz’s picture

Status: Needs work » Needs review
StatusFileSize
new53.03 KB
jrockowitz’s picture

Please review the attached patch which is finally complete and passing all tests.

  • jrockowitz committed a1969bb on 8.x-5.x
    Issue #2854879 by jrockowitz: Ability to limit the number of allowed...
jrockowitz’s picture

Status: Needs review » Fixed

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

Status: Fixed » Closed (fixed)

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