magento2-layout-debugger icon indicating copy to clipboard operation
magento2-layout-debugger copied to clipboard

Element renderer not found

Open webloft opened this issue 6 months ago • 3 comments

The extension enabled causes issues with some extensions, I can't remember right now but recently observerd with:

hyva-themes/magento2-hyva-checkout

exception.log

Element renderer for "abc" not found in "entity-form.field-renderers" {"exception":"[object] (Magento\\Framework\\Exception\\NotFoundException(code: 0): Element renderer for \"abc\" not found in \"entity-form.field-renderers\" at` ... vendor/hyva-themes/magento2-hyva-checkout/src/Model/Form/EntityFormElement/Renderer/AbstractRenderer.php:50

"abc" is just aliased for default checkout fields - all are affected.

I have no idea what's going on - it seems something is overwritten.

I have disabled the plugins

  • layout_debugger_inline_comments
  • layout_debugger_template_helper

and also the observer but it still throws the error if compiled in, so the problem must be the OpenLayout model itself.

I have also scanned the project for another custom Magento\Framework\View\LayoutInterface preference, but there is no conflict.

webloft avatar Oct 28 '25 18:10 webloft

Maybe this helps someone in future:

The problem just appears if the preference is enabled with no code executed. It seems like a Dependency Injection problem where an argument is expected in the preferenced Layout Debugger object. If you know the reference to this object you can just easily attach it again in your di.xml but I can't point to it in my case. Also possible it's some proxied stuff, I don't know.

Anyway...

Since the only reason the Layout Debugger preference exists is to provide the protected structure variable from Layout, I end up cracking the Layout object with Reflection to get the variable and re-implement the thing as plugin and now it works.

I suggest to rewrite the model to use Reflection instead so we can use plugins only.

webloft avatar Oct 28 '25 21:10 webloft

@webloft Thank you for the feedback! Can you explain what you mean by

rewrite the model to use Reflection instead so we can use plugins only?

nathanjosiah avatar Oct 29 '25 16:10 nathanjosiah

@nathanjosiah Using a class preference of Magento\Framework\View\Layout causes the DI problem - using a plugin class with eg. aroundGetOutput(). instead does not. That is my workaround.

webloft avatar Oct 30 '25 12:10 webloft