I need to add a Dynamic Rows ui component to the admin product_form.xml. I get the ui to work (the html is updated when adding and removing rows). But I cant configure the datasource/dataprovider for my dynamic rows. As I add a dataSource component inside the dynamicRows component I get errors. Is it even possible to add another datasource in the product_form component - even if it is a child component? Or do I have to modify the already existing datasource?

I get this error when adding the dataSource node:

Element 'argument': This element is not expected.
Line: 26

Element 'container': This element is not expected. Expected is ( dataSource ).
Line: 33

Verify the XML and try again.

Without the dataSource node the page loads fine. This is my product_form.xml

<?xml version="1.0" encoding="UTF-8"?>
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
        <dynamicRows name="component_name">
                <addButtonLabel translate="true">Add</addButtonLabel>
                    <param name="enabled" xsi:type="boolean">false</param>
            <dataSource name="vendor_component_name_data_source">
                <dataProvider class="Vendor\Module\Ui\DataProvider\ComponentName\DataProvider" name="component_name_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 name="provider" xsi:type="string">component_name.component_name_data_source</item>
            <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>
                <field name="from" formElement="input">
                    <argument name="data" xsi:type="array">
                        <item name="config" xsi:type="array">
                            <item name="fit" xsi:type="boolean">false</item>
                            <rule name="required-entry" xsi:type="boolean">true</rule>
                    <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>
  • Well, this pretty much ansered my question: "Using modifiers is optional and might be necessary when static declaration in XML configuration files is not suitable for the tasks. For example, in cases when additional data should be loaded from database. " developer.adobe.com/commerce/frontend-core/ui-components/…
    – Magnus
    Dec 11, 2023 at 13:39


Your Answer

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

Browse other questions tagged or ask your own question.