Magento 2 Ui insertListing in form not submitting selected values

Magento 2 Ui insertListing in form not submitting selected values

September 4, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento 2 Ui insertListing in form not submitting selected values

Magento 2 UI Form: Selecting Customers and Submitting Data

In Magento 2, using the built-in UI components can sometimes lead to unexpected behavior when trying to submit selected data from a modal grid back to the parent form. In this post, we’ll troubleshoot an issue where selected customer IDs are not being submitted along with the main form data.

The Problem: Missing Customer IDs in Post Data

Given the following XML configuration for a Magento 2 UI form:

<modal name="customers_modal">
    <argument name="data" xsi:type="array">
        <!-- Snipped for brevity -->
    </argument>
    <insertListing name="customer_listing">
        <!-- Snipped for brevity -->
    </insertListing>
</modal>

The modal loads a customer listing grid. When the “Selected” button is clicked, the selected customers are supposed to be sent back to the parent form along with other fields like name, message, and ready_to_send. However, only these main fields appear in the post data:

Array
(
    [name] => Tesy
    [ready_to_send] => false
    [message] => test
    [form_key] => bJBYSJKVwlJVVQmA
)

The customer IDs selected from the modal grid are missing.

The Cause: Data Provider Mismatch

Upon investigation, the issue lies in the data provider configuration for the modal listing. In the customer_listing_data_source argument, there is no mapping specified to send the selected data back to the parent form:

<argument name="dataProvider" xsi:type="configurableObject">
    <!-- Snipped for brevity -->
</argument>

To resolve this, we need to configure the data provider to use the same namespace as the main form.

The Solution: Configuring Data Provider

Update the customer_listing_data_source argument in your XML file:

<dataSource name="campaigns_add_form_data_source">
    <argument name="dataProvider" xsi:type="configurableObject">
        <!-- Snipped for brevity -->
    </argument>
    <argument name="data" xsi:type="array">
        <item name="js_config" xsi:type="array">
            <item name="component" xsi:type="string">Magento_Ui/js/form/components/datasource</item>
            <item name="mappings" xsi:type="array">
                <item name="customer_listing.columns.ids" xsi:type="array">
                    <item name="identifier" xsi:type="string">selected_customers_ids</item>
                </item>
            </item>
        </item>
    </argument>
</dataSource>

In the mappings array, we specify:

  • The identifier for the selected customer IDs column in the modal grid.
  • A unique identifier (e.g., selected_customers_ids) to use for these data in the main form.

Now, when you select customers and click “Selected” in the modal, the selected customer IDs should be sent back as part of the main form’s post data:

Array
(
    [name] => Tesy
    [ready_to_send] => false
    [message] => test
    [selected_customers_ids] => array(2, 3, 5)
    [form_key] => bJBYSJKVwlJVVQmA
)

Conclusion

When dealing with Magento 2 UI components, ensuring that data providers are correctly configured is crucial for submitting all relevant data from child components to the parent form. By properly mapping the selected data identifiers in the data provider configuration, we can successfully send back the necessary customer IDs along with the main form fields.

For more information on working with Magento 2’s UI XML configurations and best practices, check out our detailed guides at Laravel Company.

Happy coding!

Magento 2 Admin Configuration Customers

Our network