1

I've got an error on category saving in BO:

Warning: ltrim() expects parameter 1 to be string, array given in vendor/magento/module-catalog/Model/Category/FileInfo.php on line 102

Have simple text field, attached validation by unique value on it and fileUploader field, where exists uploaded image. Error appears only after validation failed. Fields added to category form via ui component.

Fields config:

    <field name="code">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="sortOrder" xsi:type="number">10</item>
                <item name="required" xsi:type="boolean">true</item>
                <item name="validation" xsi:type="array">
                    <item name="required-entry" xsi:type="boolean">true</item>
                </item>
                <item name="dataType" xsi:type="string">varchar</item>
                <item name="formElement" xsi:type="string">input</item>
                <item name="source" xsi:type="string">category</item>
                <item name="label" translate="true" xsi:type="string">Code</item>
                <item name="scopeLabel" xsi:type="string">[GLOBAL]</item>
                <item name="notice" xsi:type="string">Unique code of category (do not change)</item>
            </item>
        </argument>
    </field>
    <field name="header_background">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="dataType" xsi:type="string">string</item>
                <item name="source" xsi:type="string">category</item>
                <item name="label" xsi:type="string" translate="true">Header Background</item>
                <item name="formElement" xsi:type="string">fileUploader</item>
                <item name="elementTmpl" xsi:type="string">ui/form/element/uploader/uploader</item>
                <item name="previewTmpl" xsi:type="string">Magento_Catalog/image-preview</item>
                <item name="sortOrder" xsi:type="number">20</item>
                <item name="scopeLabel" xsi:type="string">[GLOBAL]</item>
                <item name="uploaderConfig" xsi:type="array">
                    <item name="url" xsi:type="url" path="catalog/category_image/upload"/>
                </item>
            </item>
        </argument>
    </field>

Made debuging category saving process. Found, that when I comment out fetching category from magento register (vendor/magento/module-catalog/Model/Category/DataProvider.php lines 411 - 414), then saving category runs ok.

Did anyone knows how I can fix it?

Thanks in advance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.