Problem/Motivation
In some cases, we can get the recur_type field's value as a string, but the code expects it to be an array.
This cause 500 error with the following message:
TypeError: Cannot access offset of type string on string in Drupal\recurring_events\Plugin\Field\FieldWidget\YearlyRecurringDateWidget->validateForm() (line 111 of /var/www/docroot/modules/contrib/recurring_events/src/Plugin/Field/FieldWidget/YearlyRecurringDateWidget.php).
Steps to reproduce
- go to edit entity with Recurring Events fields (ex. /admin/structure/events/series/types/eventseries_type/{type}/edit/form-display)
- set the weight of on of these fields smaller than the "Recur Type" field. Or just move it up Yearly Event, Daily Event, Consecutive Event, Monthly Event, Weekly Event

- save the Form Display
- go to edit entity of Event series type which the display's form settings you've just updated
- edit the entity
- save the entity
- verify that you've got an error
Proposed resolution
Let's fix it
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 2023-12-01_15-17.png | 50.19 KB | aleevas |
Issue fork recurring_events-3405567
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 #2
aleevasUnfortunately, I didn't find a reason why a change of the order of the field can change a type of the 'recur_type' field.
So, I've added a quick fix that works with both types: string and array
Comment #6
owenbush commentedI'm not sure why this would be happening, but the fix seems fair enough so I've gone ahead and merged it.