2

Is it possible to pass data available in a UI component in the form of a dataScope item:

<field name="question">
    <argument name="data" xsi:type="array">
        <item name="config" xsi:type="array">
            <item name="dataType" xsi:type="string">text</item>
            <item name="label" xsi:type="string" translate="true">Question</item>
            <item name="formElement" xsi:type="string">textarea</item>
            <item name="source" xsi:type="string">question</item>
            <item name="sortOrder" xsi:type="number">10</item>
            <item name="dataScope" xsi:type="string">question_id</item>
            <item name="validation" xsi:type="array">
                <item name="required-entry" xsi:type="boolean">true</item>
            </item>
        </item>
    </argument>
</field>

to a listing UI component included in the component using a insertListing item:

<insertListing name="test_listing_insert">
    <argument name="data" xsi:type="array">
        <item name="config" xsi:type="array">
            <item name="autoRender" xsi:type="boolean">true</item>
            <item name="dataScope" xsi:type="string">question_id</item>
            <item name="ns" xsi:type="string">test_test_listing</item></item>
    </argument>
</insertListing>
3

So the way i ended up doing this was to use a form modifier for the data provider by using the Magento Catalog as a an example.

A modifier allows you to affect the meta or structure of the ui component json which is sent to the front end for rendering. see Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Related.php

In order to filter the listing by the item id for what you are editing on the form, set a filter on the collection in the data provider for the listing using the request param for the form id. Then make sure in the get meta you set the imports and exports arrays with the following substituting the id for your id:

'imports' => [
    'seeminglyArbitraryValue' => '${ $.provider }:data.form_id_field_name'
],
'exports' => [
    'seeminglyArbitraryValue' => '${ $.externalProvider }:params.form_id_field_name'
],

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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