Note, this is a clone of a previous issue - the problem I am having is the exact same as closed issue #3401667.
Problem/Motivation
Adding multiple Office Hours fields both configured with the "Exceptions" functionality doesn't work.
It seems like this might be a known issue in code, but I didn't find any reported issue in the issue queue.
Notice the @todo comment on line 23 here:
https://git.drupalcode.org/project/office_hours/-/blob/8.x-1.x/src/Plugi...
Steps to reproduce
- Add and configure an "Office Hours" field on a Content Type. Enable the "Exceptions" feature (field settings + widget)
- Add another "Office Hours" field on the same Content Type, also enabling the same settings as above.
- Populate both fields as needed
- Click "Add exception" in one of the widgets
- Notice that the exception row is added to the incorrect field. Interacting with the "Add exception" button on either field has sporadic results
Proposed resolution
The widget interactions should be tied to the field instance, not just "the first office hours field in the form".
Remaining tasks
Narrow-down the issue and come up with a route to fix it.
Comments
Comment #2
mikaylaflanagan commentedComment #3
johnvIndeed, I see many more problems:
- no problem with the 'Add exception' buttons
- both fields have the same title
- when first adding an exception one second field, then save, then add exception on other field, the value of first field is prefilled.
Comment #5
johnvThe above commit should solve the problem.
Please test and report back. Then I will release a new version.
Comment #6
mikaylaflanagan commentedHey - thanks for the reply!
Just tested this, getting WSOD and the following error in logs when trying to edit a node that has the office hour field.
'Error: Cannot access protected property Drupal\field\Entity\FieldConfig::$id in Drupal\office_hours\Plugin\Field\FieldType\OfficeHoursItemList->getPlugin() (line 276 of /modules/contrib/office_hours/src/Plugin/Field/FieldType/OfficeHoursItemList.php).'Maybe helpful context:
Drupal Core: 10.4.5
PHP: 8.2
EDIT/UPDATE
I manually changed
$id = $field_definition->id;to
$id = $field_definition->id();on line 276 of Plugin/Field/FieldType/OfficeHoursItemList.php and things are working for me now on my test.
Comment #7
johnvOh, I am working on 8.3 I think I must go back to 8.2, because I get more such problems reported.
Comment #9
johnv