Open
Description
Bug description
Since 4.51.0 the field()->parent() is set to some other entry.
I have a custom fieldtype which needs the entry id to populate data from an API. I do this in the preload() method using $this->field()->parent()
Since 4.51.0 this resolves some random entry, but not the correct one. Most of the time the last entry in the structure tree (I noticed the bug in a structured collection).
How to reproduce
Use a custom fieldtype and check the parent:
<?php
namespace App\Fieldtypes;
use Statamic\Fields\Fieldtype;
class Sections extends Fieldtype
{
public function preload()
{
ray($this->field()?->parent());
ray($this->field()?->parent()->id());
$parentEntry = $this->field()?->parent()->id();
self::appendConfigField('parent_entry', [
'type' => 'text',
'default' => $parentEntry,
]);
return ['parent_entry' => $parentEntry];
}
}
Logs
No response
Environment
php 8.3.3
laravel 10.46.0
statamic 4.51.0
Installation
Fresh statamic/statamic site via CLI
Antlers Parser
Runtime (default)
Additional details
No response