0

I have created my own custom module. Entity like Block and Page of module cms. Everything ok. My form can save data to db. In my form i have field to set which store to belong. It like cms blog store implement. But after load, store data seem not set in grid Why it happen? In grid ui column store empty. Grid JSON show store_id empty And in form store data not set. But data in db existed. What did i do wrong? How to make form set data for select store field

1 Answer 1

0

Finally i found my problems

Some parts in my etc/di.xml file

<type name="{{Namespace}}\{{Module}}\Model\ResourceModel\{{Entity}}\Grid\Collection">
    <arguments>
        <argument name="mainTable" xsi:type="string">{{your-entity-table}}</argument>
        <argument name="eventPrefix" xsi:type="string">{{youreventprefix}}</argument>
        <argument name="eventObject" xsi:type="string">{{youreventobject}}</argument>
        <argument name="resourceModel" xsi:type="string">{{Namespace}}\{{Module}}\Model\ResourceModel\{{Entity}}</argument>
    </arguments>
</type>

<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
    <arguments>
        <argument name="collections" xsi:type="array">
            <item name="your_listing_data_source" xsi:type="string">{{Namespace}}\{{Module}}\Model\ResourceModel\{{Entity}}\Grid\Collection</item>
        </argument>
    </arguments>
</type>

No need this below

<virtualType name="{{Namespace}}\{{Module}}\Model\ResourceModel\{{Entity}}\Collection" type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
    <arguments>
        <argument name="mainTable" xsi:type="string">{{your-entity-table}}</argument>
        <argument name="eventPrefix" xsi:type="string">{{youreventprefix}}</argument>
        <argument name="eventObject" xsi:type="string">{{youreventobject}}</argument>
        <argument name="resourceModel" xsi:type="string">{{Namespace}}\{{Module}}\Model\ResourceModel\{{Entity}}</argument>
    </arguments>
</virtualType>

New GridUI comes with some implement interface you can see in module-cms
Don't forget Grid Collection located in

{{Namespace}}\{{Module}}\Model\ResourceModel\{{Entity}}\Grid\Collection. This implement SearchResultInterface for get collection data of entity and populate all to your grid

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.