Allow multiple values

Created on 6 April 2024, 8 months ago
Updated 30 May 2024, 6 months ago

Problem/Motivation

I'm working on a project where selecting multiple slots from the same day would be required. I'd be happy to take a stab at, hoping to get your input first on what I think I should do.

As a brute first try I added the 'multiple' option to the element config options and set my element to allow 3 values. The text input seems to work without a problem, I'm able to add another value, and when entering two values, both get saved properly and behave like a multivalue field in submissions views.
Also, when I open the same form again, both previously submitted slot options are greyed out, so this seems to be handled properly by design of the "isSlotSelected" function in the module.

Proposed resolution

The slot selection UI (webform_booking.js) needs some adjustments because it's built for a single-value element.
Tasks I see at first glance:
- Load number of allowed values from element config, and change selection logic accordingly.
Changes required when more than 1 value is allowed:
- selecting/deselecting a slot option should add/remove that value from the text field form element (if allowed maximum is not reached yet, or there's no limit) but it should not reset the text field
- if the allowed number of options is has been reached, clicking an additional option should either be impossible (all slots deactivated), or we should throw a message about maximum being reached.

Anything else that comes to mind and might not be obvious?

Remaining tasks

Rewrite js as described above, create patch, test.

User interface changes

Not expected.

Data model changes

None, storing of submitted values are handled by main Webform module which is already able to do multivalue.

Feature request
Status

Active

Version

1.0

Component

Code

Created by

🇭🇺Hungary dr. gubó

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @dr. gubó
  • 🇭🇺Hungary dr. gubó

    - Selecting another month or day on the widget should not reset the text field that stores the already selected value
    - We should consider how it's best to display any selected values that are not submitted yet. If we select a slot from one day and then change the widget to another day, the selected slot should stay visible in some form.

  • 🇭🇺Hungary dr. gubó

    This would also solve Allow booking of whole days Allow booking of whole days Active without introducing any new operation logic.

  • 🇵🇹Portugal rfmarcelino

    Thank you @dr gubó
    Yes, this would require some changes.
    To be considered in an upcoming development cycle.

  • 🇨🇦Canada rleroux

    Hello,
    I strongly second this feature request. Would be very userful.
    Thank you!

Production build 0.71.5 2024