Skip to content

In Model Edit, display filtered grid of another Model

Consider two models, Foo and Bar. The Bar model has a non-nullable field foo_id which is associated with a Foo object.

<?xml version="1.0" ?>
<schema xmlns:xsi="..." xsi:noNamespaceSchemaLocation="...">

    <table name="dc_foos_foo" resource="default" engine="innodb">
        <column xsi:type="int" name="foo_id" padding="10" unsigned="true" nullable="false" identity="true"/>
        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="foo_id"/>
        </constraint>
        <column name="foo_name" nullable="false" xsi:type="text"/>
    </table>

    <table name="dc_foos_bar" resource="default" engine="innodb">
        <column xsi:type="int" name="bar_id" padding="10" unsigned="true" nullable="false" identity="true">
        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="bar_id"/>
        </constraint>
        <column name="foo_id" nullable="false" xsi:type="int"/>
        <column name="bar_name" nullable="false" xsi:type="text"/>
    </table>

</schema>

I would like to display the Grid for managing Bar objects inside the Edit page of the Foo model. That is, when editing the Foo object with ID 42, there will be a fieldset of all Bar objects whose foo_id is 42. How is such a fieldset added?

I’ve looked at implementations of core classes, e.g. MagentoStoreUiComponentFormFieldsetWebsites and MagentoCustomerUiComponentFormAddressFieldset which I believed to relevant as other Models’ UI Components reference them. However I’ve found nothing of usable substance in either Modules’ relevant files or other files. Of course, I’ve futilely purused Adobe Developer’s PHP Developer Guide Component development but as expected there was no relevant information there, either.