Magento2 – Fix Fatal Error in Ui TemplateEngine Xhtml Result

admincategoryeditmagento2

Please check below error:

Fatal error: Method
Magento\Ui\TemplateEngine\Xhtml\Result::__toString() must not throw an
exception, caught Error: Cannot use string offset as an array in
/vendor/magento/module-ui/Component/Wrapper/UiComponent.php
on line 0

I can see the above error when I go to the admin > Catalog > Manage Category
and choose any category to edit.

Please help me if you face any kind of this issues?

Thanks in advance!

Best Answer

I just fixed the above mention issue which I mention in my question.

I got the error is actually coming from the Core files.

Just go to the file using below path: > /vendor/magento/module-catalog/Model/Category/DataProvider.php

Should use $attributeCode as lines 495 & 496 rather than hardcoded ['image']

Like below code

$categoryData[$attributeCode][0]['size'] = isset($stat) ? $stat['size'] : 0;
$categoryData[$attributeCode][0]['type'] = $mime;

I hope its working for you as well.

Related Topic