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.