Problem/Motivation
The "No slots available message" field in the element configuration does not display its default value ("No slots available.") on the form. If the default value is changed to any other value, the message is correctly displayed when no slots are available for a selected day.
Steps to reproduce
- Add an "Appointment Booking" element to a webform.
- Leave the default value of the "No slots available message" configuration field unchanged.
- Book all available slots for a specific day.
- Observe that the message "No slots available." is not displayed on the form.
Proposed resolution
In the WebformBooking.php file, within the prepare() function (around line 456), an empty string is currently passed to the JavaScript DrupalSettings object when the element's #no_slots value is empty or unset:
'noSlots' => $element['#no_slots'] ?? '',
In webform_booking.js (around line 20), if the noSlots variable is empty, the default message "No slots available" is expected to display:
const noSlots = elementConfig.noSlots ?? 'No slots available';
However, since an empty string is passed to noSlots instead of NULL, only the empty string is displayed, and the default message is not shown as intended.
Fix:
Update the code in the prepare() function to pass NULL instead of an empty string:
'noSlots' => $element['#no_slots'] ?? NULL,
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | webform_booking-default_value_of-3499252.patch | 1.02 KB | electric.larry |
Issue fork webform_booking-3499252
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
electric.larry commentedHere's a patch that should fix issue #3499252.
Comment #4
electric.larry commentedComment #5
rfmarcelino commentedThank you @electric.larry .
Tested. Merging the MR.
Comment #6
rfmarcelino commentedComment #7
rfmarcelino commented