Skip to content

DynamicRows component doesn’t show saved data on edit form (Adminhtml)

The ui form component works good on “New” action but, if I save this:

New action

Then, the edit action shows this:

Edit action

The data is being saved correctly in my custom table after submitting the “New” action.

Here is the dynamicRows section of my ui form layout:

   <container name="attribute_code_container">
      <dynamicRows name="attribute_code">
        <settings>
            <componentType>dynamicRows</componentType>
            <label translate="true">Attributes / Fields</label>
            <columnsHeader>false</columnsHeader>
            <addButton>true</addButton>
            <addButtonLabel translate="true">Add attribute</addButtonLabel>
            <deleteProperty>false</deleteProperty>
            <dndConfig>
                <param name="enabled" xsi:type="boolean">false</param>
            </dndConfig>
        </settings>
        <container name="record" component="Magento_Ui/js/dynamic-rows/record">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="isTemplate" xsi:type="boolean">true</item>
                    <item name="is_collection" xsi:type="boolean">true</item>
                    <item name="componentType" xsi:type="string">container</item>
                </item>
            </argument>
            <field name="attribute_code" formElement="select">
              <formElements>
                  <select>
                      <settings>
                          <options class="VendorModuleModelSourceAttribute"/>
                      </settings>
                  </select>
              </formElements>
            </field>
            <actionDelete>
                <argument name="data" xsi:type="array">
                    <item name="config" xsi:type="array">
                        <item name="componentType" xsi:type="string">actionDelete</item>
                        <item name="dataType" xsi:type="string">text</item>
                        <item name="label" xsi:type="string">Delete</item>
                        <item name="template" xsi:type="string">Magento_Backend/dynamic-rows/cells/action-delete</item>
                    </item>
                </argument>
            </actionDelete>
        </container>
      </dynamicRows>
    </container>

The VendorModuleModelSourceAttribute class seems to be OK,try with MagentoConfigModelConfigSourceYesno (For example) I get the same result.

What is wrong with the dynamicRows component and how can I set an instruction to get the data from my custom table the right way?