Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
The office hours widget contains a field to add a comment per time slot. This field may not be applicable for every use case, so let's make it an option in the Field settings.
In the D7 version, the Comment is already made optional is the issue #2863233: Make the new 'Comment' per entry optional and opt-in
Proposed resolution
Make the 'Comment' value optional and opt-out per field instance.
Remaining tasks
- Write a patch
- Review
- Commit
User interface changes
The 'Comment' field per office hour is only available when enabled in the field instance configuration.
API changes
None.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#6 | office_hours-make_comment_optional-2888121-5.patch | 708 bytes | johannijdam |
#2 | office_hours-make_comment_optional-2888121-2.patch | 4.63 KB | idebr |
Comments
Comment #2
idebr CreditAttribution: idebr at ezCompany commentedAttached patch implements a new field setting "Allow a comment per time slot" similar to the D7 implementation.
Comment #4
johnvThanks.
Changed some more parts, and did not remove, but hide the Comment element.
Regards from Utrecht :-)
Comment #5
johannijdam CreditAttribution: johannijdam commentedI found out that I get a warning when I'm saving a office hours field, like
Notice: Undefined offset: 0 in Drupal\office_hours\Plugin\Field\FieldType\OfficeHoursItemList->compressSlots() (line 183 of modules/contrib/office_hours/src/Plugin/Field/FieldType/OfficeHoursItemList.php).
I fixed it changing the OfficeHoursItemList.php:181
if (is_array($info['slots']) && !empty($info['slots'])) {
instead of
if (is_array($info['slots'])) {
Comment #6
johannijdam CreditAttribution: johannijdam commentedPlease see my patch attached
Comment #7
johannijdam CreditAttribution: johannijdam commentedComment #8
Martijn de WitComment #10
johnvThanks.