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
field
- 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

CommentFileSizeAuthor
#2 2023-12-01_15-17.png50.19 KBaleevas
Command icon 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

aleevas created an issue. See original summary.

aleevas’s picture

Issue summary: View changes
StatusFileSize
new50.19 KB

Unfortunately, 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

owenbush made their first commit to this issue’s fork.

  • owenbush committed 98c2ccee on 2.0.x authored by aleevas
    Issue #3405567 by aleevas, owenbush: TypeError: Cannot access offset of...
owenbush’s picture

Status: Active » Fixed

I'm not sure why this would be happening, but the fix seems fair enough so I've gone ahead and merged it.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.