- Issue created by @electric.larry
- Merge request !9Pass NULL to display default message instead of empty string. → (Merged) created by Unnamed author
- 🇦🇹Austria electric.larry Vienna
Here's a patch that should fix issue #3499252.
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.
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,
Active
1.1
Code
Here's a patch that should fix issue #3499252.