-
Notifications
You must be signed in to change notification settings - Fork 641
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[5.x]: Fix Typed property craft\base\FieldLayoutComponent::$elementType must not be accessed before initialization
error with Kint and element queries
#15074
Comments
This is definitely a Kint bug. Replacing To be extra sure, I installed Kint and set a breakpoint in the The field layout/tab/element’s |
So the That's me just calling It's the I'm keenly aware that this is probably a "my problem" sort of issue, as |
Ah ok, sorry, got confused. I just set that property to |
Thanks for that, yeah probably my issue to figure out now. It's likely all to do with the kint-twig package just being stupid, but that's my problem now 😄 |
Craft 5.1.8 is out with that fix. |
What happened?
Refer to verbb/kint#8 but since Craft 5, the plugin cannot dump
ElementQuery
objects anymore. This is due to an error:Typed property craft\base\FieldLayoutComponent::$elementType must not be accessed before initialization
.To reproduce this, add an Entries field to an Entry, then use Kint to output the ElementQuery (not an element collection or single element):
{{ d(craft.entries.id(123).one().entriesField) }}
Disregarding the Kint factor here, I feel like this might be a Craft issue.
Taking a deep-dive into things, this seems to be due to the
craft\fieldlayoutelements\CustomField
(our Entries field) doesn't have anelementType
associated with it yet. It's also during this investigation that I've found when settings elements on aFieldLayoutTab
that it's ownelementType
isn't set.I'm not 110% sure, but shouldn't the
elementType
for theFieldLayoutTab
and resultingCustomField
objects be inherited from theFieldLayout::type
property? The element type that the field layout is for?Which seems to fix my issue. I didn't do a PR, purely because I'm not really sure if this is right, expected behaviour or otherwise.
Craft CMS version
5.1.7
PHP version
8.2.0
Operating system and version
MacOS 14.1
Database type and version
MySQL 8
Image driver and version
No response
Installed plugins and versions
The text was updated successfully, but these errors were encountered: