M2 ee2.2.7后台form一直加载不出来的问题。

5.54K 浏览M2交流区

M2 ee2.2.7后台form一直加载不出来的问题。

我通过ui component的方式创建了一个后台的form,页面刷新后加载了input元素,但是没有数据,界面一直存在一个加载图标。如下图:

分别是两个创建和修改的layout文件内容以及ui component文件内容。我尝试从magento已有的文件copy过来修改,以及网上很多版本,都无法正确加载

ui-component代码

<?xml version="1.0" encoding="UTF-8"?>
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <argument name="data" xsi:type="array">
        <item name="js_config" xsi:type="array">
            <item name="provider" xsi:type="string">categoryurlrewrite_index_view.categoryurlrewrite_index_view_data_source</item>
        </item>
        <item name="namespace" xsi:type="string">categoryurlrewrite_index_view</item>
        <item name="label" xsi:type="string" translate="true">Rewrite Information</item>
        <item name="template" xsi:type="string">templates/form/collapsible</item>
    </argument>
    <settings>
        <buttons>
            <button name="save" class="PyyCategoryUrlRewriteBlockAdminhtmlFormEditSaveButton"/>
            <button name="delete" class="PyyCategoryUrlRewriteBlockAdminhtmlFormEditDeleteButton"/>
            <button name="back" class="PyyCategoryUrlRewriteBlockAdminhtmlFormEditBackButton"/>
        </buttons>
        <dataScope>data</dataScope>
        <deps>
            <dep>categoryurlrewrite_index_view.categoryurlrewrite_index_view_data_source</dep>
        </deps>
    </settings>
    <dataSource name="categoryurlrewrite_index_view_data_source">
        <argument name="data" xsi:type="array">
            <item name="js_config" xsi:type="array">
                <item name="component" xsi:type="string">Magento_Ui/js/form/provider</item>
            </item>
        </argument>
        <settings>
            <submitUrl path="categoryurlrewrite/index/save"/>
        </settings>
        <dataProvider class="PyyCategoryUrlRewriteModelDataProvider" name="categoryurlrewrite_index_view_data_source">
            <settings>
                <requestFieldName>id</requestFieldName>
                <primaryFieldName>id</primaryFieldName>
            </settings>
        </dataProvider>
    </dataSource>
    <fieldset name="general">
        <settings>
            <label/>
        </settings>
        <field name="id" formElement="input">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="source" xsi:type="string">categorydata</item>
                </item>
            </argument>
            <settings>
                <dataType>text</dataType>
                <visible>false</visible>
                <dataScope>id</dataScope>
            </settings>
        </field>
        <field name="category_id" sortOrder="10"  formElement="input">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="source" xsi:type="string">categorydata</item>
                </item>
            </argument>
            <settings>
                <validation>
                    <rule name="required-entry" xsi:type="boolean">true</rule>
                </validation>
                <dataType>text</dataType>
                <label translate="true">Category Id</label>
                <dataScope>category_id</dataScope>
            </settings>
        </field>
        <field name="active" sortOrder="30" formElement="checkbox">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="source" xsi:type="string">categorydata</item>
                    <item name="default" xsi:type="number">1</item>
                </item>
            </argument>
            <settings>
                <dataType>boolean</dataType>
                <label translate="true">Is Active</label>
                <dataScope>active</dataScope>
            </settings>
            <formElements>
                <checkbox>
                    <settings>
                        <valueMap>
                            <map name="false" xsi:type="number">0</map>
                            <map name="true" xsi:type="number">1</map>
                        </valueMap>
                        <prefer>toggle</prefer>
                    </settings>
                </checkbox>
            </formElements>
        </field>
        <field name="cms_id" sortOrder="20" formElement="input">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="source" xsi:type="string">categorydata</item>
                </item>
            </argument>
            <settings>
                <validation>
                    <rule name="required-entry" xsi:type="boolean">true</rule>
                </validation>
                <dataType>text</dataType>
                <label translate="true">CMS Page Id</label>
                <dataScope>cms_id</dataScope>
            </settings>
        </field>
    </fieldset>
</listing>

dataprovider里面数据返回是正常的

。button类也是正常的

PS:问题已经解决了,还是因为自己太粗心导致的。xml里面应该是form 而不是listing

然后dataprovider应该更改继承:

0

js里没报错?
network里请求的url有没有哪个是500错误的?

0

都没有,日志也没有报错信息

0