You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a collection that links to a fieldset that a few other collections use. The fieldset is a replicator with a variable number of sets.
Creating a new entry in that collection without adding anything to the linked replicator causes the Illegal string offset 'type' exception after saving it and navigating back to it.
Interestingly, this doesn't happen if the collection's blueprint only contains the linked replicator, but if you add other fields to the collection's blueprint the error occurs.
How to Reproduce
Create a field set that contains a replicator.
Create a new collection
In the new collection's blueprint add any field and add a field linked to the field set.
Create a new entry and save it without adding content to linked replicator field.
The issue is that an empty string makes it's way to line 47 of the Replicator, but because you are using a null coalescing operator (which doesn't work on empty strings) - the default value isn't being assigned.
So line 209 in Field.php should be rewritten with the elvis operator:
Obviously this is a deeper issue and I'm just whackamoling so I can get it to work. I read in other issues that having the linked replicator field named 'content' was causing issues before, but that issue was resolved in 3.x?
Bug Description
I have a collection that links to a fieldset that a few other collections use. The fieldset is a replicator with a variable number of sets.
Creating a new entry in that collection without adding anything to the linked replicator causes the
Illegal string offset 'type'
exception after saving it and navigating back to it.Interestingly, this doesn't happen if the collection's blueprint only contains the linked replicator, but if you add other fields to the collection's blueprint the error occurs.
How to Reproduce
I've attached yaml configs: statamic-fieldset-bug.zip
Extra Detail
The error happend in line 47 of
vendor/statamic/cms/src/FieldStypes/Replicator.php
I think the actual issue is further up the stack in:
cms/src/Fields/Field.php
Line 209 in 64eadfd
The issue is that an empty string makes it's way to line 47 of the Replicator, but because you are using a null coalescing operator (which doesn't work on empty strings) - the default value isn't being assigned.
So line 209 in Field.php should be rewritten with the elvis operator:
Environment
Statamic version: 3.0.19
Laravel: 8.10.0
PHP version: 7.4
Install method (choose one):
statamic/statamic
The text was updated successfully, but these errors were encountered: