Magento 2 dynamicRows as new tab for admin customer edit, how do you get data loaded?Magento 2 add new tab in customer dashboard frontendNew Tab in Admin Product Edit in Custom ModuleMagento 2.1 Create a filter in the product grid by new attributeMagento 2 Add new field to Magento_User admin formMagento 2. Customer Edit TabGet customer data in Additional template file in customer account editMagento2 REST API get all customers detailsHow To Add Custom Data Into Product Edit Form DynamicRows Ui ComponentMagento 2 custom tab on customer section in admin panelHow to remove/hide a tab in customer admin edit in magento 2

How to make a pipeline wait for end-of-file or stop after an error?

Pass By Reference VS Pass by Value

Is there a way to get a compiler for the original B programming language?

What happened to Captain America in Endgame?

Does Gita support doctrine of eternal samsara?

Why was the Spitfire's elliptical wing almost uncopied by other aircraft of World War 2?

Sci fi novel series with instant travel between planets through gates. A river runs through the gates

how to find the equation of a circle given points of the circle

Do I have an "anti-research" personality?

What was the first Intel x86 processor with "Base + Index * Scale + Displacement" addressing mode?

Is there really no use for MD5 anymore?

Why do Computer Science majors learn Calculus?

Fizzy, soft, pop and still drinks

What is the most expensive material in the world that could be used to create Pun-Pun's lute?

US visa is under administrative processing, I need the passport back ASAP

simple conditions equation

Why was Germany not as successful as other Europeans in establishing overseas colonies?

What does KSP mean?

Does a semiconductor follow Ohm's law?

How to reduce LED flash rate (frequency)

What does the "ep" capability mean?

Does holding a wand and speaking its command word count as V/S/M spell components?

How to stop co-workers from teasing me because I know Russian?

How to type a section sign (§) into the Minecraft client



Magento 2 dynamicRows as new tab for admin customer edit, how do you get data loaded?


Magento 2 add new tab in customer dashboard frontendNew Tab in Admin Product Edit in Custom ModuleMagento 2.1 Create a filter in the product grid by new attributeMagento 2 Add new field to Magento_User admin formMagento 2. Customer Edit TabGet customer data in Additional template file in customer account editMagento2 REST API get all customers detailsHow To Add Custom Data Into Product Edit Form DynamicRows Ui ComponentMagento 2 custom tab on customer section in admin panelHow to remove/hide a tab in customer admin edit in magento 2






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















How can I load the data from customer DataProvider plugin into my ui_component dynamicRows?



I have created a new tab in the admin customer edit form, and added my ui_component, which seems to work well. But I can't populate the data already stored in my database.



I have tried to add xml for DataSource, but I think that has conflict with original customer_form.xml DataSource "customer_form.customer_form_data_source" because when I add DataSource, the page no longer loads.



dataSource XML:



<dataSource name="mycustomrows">
<argument name="dataProvider" xsi:type="configurableObject">
<argument name="class" xsi:type="string">MyVendorMyModuleModelCustomerDataProvider</argument>
<argument name="primaryFieldName" xsi:type="string">id</argument>
<argument name="requestFieldName" xsi:type="string">id</argument>
<argument name="meta" xsi:type="array">
<item name="mycustomrows" xsi:type="array">
<item name="config" xsi:type="array">
<item name="label" xsi:type="string" translate="true">My Custom Rows</item>
</item>
</item>
</argument>
<argument name="data" xsi:type="array">
<item name="js_config" xsi:type="array">
<item name="component" xsi:type="string">Magento_Ui/js/grid/provider</item>
</item>
</argument>
</argument>
<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>
</argument>
</dataSource>


dataProvider for dataSource:



<?php

namespace MyVendorMyModuleModelCustomer;

class DataProvider extends MagentoUiDataProviderAbstractDataProvider

protected $loadedData;
protected $collectionFactory;

public function __construct(
$name,
$primaryFieldName,
$requestFieldName,
MyVendorMyModuleModelResourceModelRowCollection $collection,
MyVendorMyModuleModelResourceModelRowCollectionFactory $collectionFactory,
array $meta = [],
array $data = []
)
$this->collection = $collection;
$this->collectionFactory = $collectionFactory;

parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);


public function getData()

if (isset($this->loadedData))
return $this->loadedData;


$collection = $this->collectionFactory->create();
// add Filter for Customer ID
//->setOrder('position', 'ASC');
$items = $collection->getItems();

foreach ($items as $item)
$this->loadedData[$item->getId()] = $item->getData();


return $this->loadedData;




I believe the data has to be loaded with Plugin for "MagentoCustomerModelCustomerDataProvider" as I am doing below, but I can't seem to get populate rows on load.



view/adminhtml/ui_component/customer_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">
<fieldset name="mycustomrows">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="label" xsi:type="string" translate="true">My Custom Rows</item>
<item name="sortOrder" xsi:type="number">10</item>
</item>
</argument>
<dynamicRows name="mycustomrows">
<settings>
<addButtonLabel translate="true">Add Row</addButtonLabel>
<additionalClasses>
<class name="admin__field-wide">true</class>
</additionalClasses>
<componentType>dynamicRows</componentType>
</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 name="positionProvider" xsi:type="string">position</item>
</item>
</argument>


<field name="mycustomrows_select1" formElement="select" sortOrder="10">
<settings>
<dataType>text</dataType>
<label translate="true">Select Field 1</label>
<disabled>false</disabled>
<dataScope>mycustomrows_select1</dataScope>
</settings>
<formElements>
<select>
<settings>
<options class="MyVendorMyModuleModelSourceSelectFieldOne"/>
</settings>
</select>
</formElements>
</field>
<field name="mycustomrows_input1" sortOrder="20" formElement="input">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="source" xsi:type="string">customer</item>
</item>
</argument>
<settings>
<label translate="true">Text Field 1</label>
<dataType>text</dataType>
<dataScope>mycustomrows_text1</dataScope>
</settings>
</field>
<actionDelete sortOrder="30">
<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="fit" xsi:type="boolean">false</item>
<item name="label" xsi:type="string">Actions</item>
<item name="sortOrder" xsi:type="string">500</item>
<item name="additionalClasses" xsi:type="string">data-grid-actions-cell</item>
<item name="template" xsi:type="string">Magento_Backend/dynamic-rows/cells/action-delete</item>
</item>
</argument>
</actionDelete>
</container>
</dynamicRows>
</fieldset>
</form>


etc/adminhtml/di.xml



<?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="MagentoCustomerModelCustomerDataProvider">
<plugin name="customer_get_mycustomrows" type="MyVendorMyModuleModelCustomerDataProvider" sortOrder="5" />
</type>
</config>


Model/Customer/DataProvider.php



<?php
namespace MyVendorMyModuleModelCustomer;

class DataProvider

protected $collection;
protected $collectionFactory;
protected $loadedData;

public function __construct(
MyVendorMyModuleModelResourceModelRowCollection $collection,
MyVendorMyModuleModelResourceModelRowCollectionFactory $collectionFactory,
array $data = []
)
$this->collection = $collection;
$this->collectionFactory = $collectionFactory;


public function afterGetData(MagentoCustomerModelCustomerDataProvider $subject, $result)

if($result)
$customer_id = key($result);
$customerData = $result[$customer_id]['customer'];

if(is_null($this->loadedData))
$this->loadedData = array();
$collection = $this->collectionFactory->create(); //->setOrder('position', 'ASC');
$items = $collection->getItems();

foreach ($items as $item)
$this->loadedData[] = $item->getData();



$result[$customer_id]['customer']["mycustomrows"] = $this->loadedData;

return $result;





I can't seem to get any records populated when I load a customer edit page.









share







New contributor




Cmaclean066 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


























    0















    How can I load the data from customer DataProvider plugin into my ui_component dynamicRows?



    I have created a new tab in the admin customer edit form, and added my ui_component, which seems to work well. But I can't populate the data already stored in my database.



    I have tried to add xml for DataSource, but I think that has conflict with original customer_form.xml DataSource "customer_form.customer_form_data_source" because when I add DataSource, the page no longer loads.



    dataSource XML:



    <dataSource name="mycustomrows">
    <argument name="dataProvider" xsi:type="configurableObject">
    <argument name="class" xsi:type="string">MyVendorMyModuleModelCustomerDataProvider</argument>
    <argument name="primaryFieldName" xsi:type="string">id</argument>
    <argument name="requestFieldName" xsi:type="string">id</argument>
    <argument name="meta" xsi:type="array">
    <item name="mycustomrows" xsi:type="array">
    <item name="config" xsi:type="array">
    <item name="label" xsi:type="string" translate="true">My Custom Rows</item>
    </item>
    </item>
    </argument>
    <argument name="data" xsi:type="array">
    <item name="js_config" xsi:type="array">
    <item name="component" xsi:type="string">Magento_Ui/js/grid/provider</item>
    </item>
    </argument>
    </argument>
    <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>
    </argument>
    </dataSource>


    dataProvider for dataSource:



    <?php

    namespace MyVendorMyModuleModelCustomer;

    class DataProvider extends MagentoUiDataProviderAbstractDataProvider

    protected $loadedData;
    protected $collectionFactory;

    public function __construct(
    $name,
    $primaryFieldName,
    $requestFieldName,
    MyVendorMyModuleModelResourceModelRowCollection $collection,
    MyVendorMyModuleModelResourceModelRowCollectionFactory $collectionFactory,
    array $meta = [],
    array $data = []
    )
    $this->collection = $collection;
    $this->collectionFactory = $collectionFactory;

    parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);


    public function getData()

    if (isset($this->loadedData))
    return $this->loadedData;


    $collection = $this->collectionFactory->create();
    // add Filter for Customer ID
    //->setOrder('position', 'ASC');
    $items = $collection->getItems();

    foreach ($items as $item)
    $this->loadedData[$item->getId()] = $item->getData();


    return $this->loadedData;




    I believe the data has to be loaded with Plugin for "MagentoCustomerModelCustomerDataProvider" as I am doing below, but I can't seem to get populate rows on load.



    view/adminhtml/ui_component/customer_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">
    <fieldset name="mycustomrows">
    <argument name="data" xsi:type="array">
    <item name="config" xsi:type="array">
    <item name="label" xsi:type="string" translate="true">My Custom Rows</item>
    <item name="sortOrder" xsi:type="number">10</item>
    </item>
    </argument>
    <dynamicRows name="mycustomrows">
    <settings>
    <addButtonLabel translate="true">Add Row</addButtonLabel>
    <additionalClasses>
    <class name="admin__field-wide">true</class>
    </additionalClasses>
    <componentType>dynamicRows</componentType>
    </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 name="positionProvider" xsi:type="string">position</item>
    </item>
    </argument>


    <field name="mycustomrows_select1" formElement="select" sortOrder="10">
    <settings>
    <dataType>text</dataType>
    <label translate="true">Select Field 1</label>
    <disabled>false</disabled>
    <dataScope>mycustomrows_select1</dataScope>
    </settings>
    <formElements>
    <select>
    <settings>
    <options class="MyVendorMyModuleModelSourceSelectFieldOne"/>
    </settings>
    </select>
    </formElements>
    </field>
    <field name="mycustomrows_input1" sortOrder="20" formElement="input">
    <argument name="data" xsi:type="array">
    <item name="config" xsi:type="array">
    <item name="source" xsi:type="string">customer</item>
    </item>
    </argument>
    <settings>
    <label translate="true">Text Field 1</label>
    <dataType>text</dataType>
    <dataScope>mycustomrows_text1</dataScope>
    </settings>
    </field>
    <actionDelete sortOrder="30">
    <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="fit" xsi:type="boolean">false</item>
    <item name="label" xsi:type="string">Actions</item>
    <item name="sortOrder" xsi:type="string">500</item>
    <item name="additionalClasses" xsi:type="string">data-grid-actions-cell</item>
    <item name="template" xsi:type="string">Magento_Backend/dynamic-rows/cells/action-delete</item>
    </item>
    </argument>
    </actionDelete>
    </container>
    </dynamicRows>
    </fieldset>
    </form>


    etc/adminhtml/di.xml



    <?xml version="1.0"?>

    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="MagentoCustomerModelCustomerDataProvider">
    <plugin name="customer_get_mycustomrows" type="MyVendorMyModuleModelCustomerDataProvider" sortOrder="5" />
    </type>
    </config>


    Model/Customer/DataProvider.php



    <?php
    namespace MyVendorMyModuleModelCustomer;

    class DataProvider

    protected $collection;
    protected $collectionFactory;
    protected $loadedData;

    public function __construct(
    MyVendorMyModuleModelResourceModelRowCollection $collection,
    MyVendorMyModuleModelResourceModelRowCollectionFactory $collectionFactory,
    array $data = []
    )
    $this->collection = $collection;
    $this->collectionFactory = $collectionFactory;


    public function afterGetData(MagentoCustomerModelCustomerDataProvider $subject, $result)

    if($result)
    $customer_id = key($result);
    $customerData = $result[$customer_id]['customer'];

    if(is_null($this->loadedData))
    $this->loadedData = array();
    $collection = $this->collectionFactory->create(); //->setOrder('position', 'ASC');
    $items = $collection->getItems();

    foreach ($items as $item)
    $this->loadedData[] = $item->getData();



    $result[$customer_id]['customer']["mycustomrows"] = $this->loadedData;

    return $result;





    I can't seem to get any records populated when I load a customer edit page.









    share







    New contributor




    Cmaclean066 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.






















      0












      0








      0








      How can I load the data from customer DataProvider plugin into my ui_component dynamicRows?



      I have created a new tab in the admin customer edit form, and added my ui_component, which seems to work well. But I can't populate the data already stored in my database.



      I have tried to add xml for DataSource, but I think that has conflict with original customer_form.xml DataSource "customer_form.customer_form_data_source" because when I add DataSource, the page no longer loads.



      dataSource XML:



      <dataSource name="mycustomrows">
      <argument name="dataProvider" xsi:type="configurableObject">
      <argument name="class" xsi:type="string">MyVendorMyModuleModelCustomerDataProvider</argument>
      <argument name="primaryFieldName" xsi:type="string">id</argument>
      <argument name="requestFieldName" xsi:type="string">id</argument>
      <argument name="meta" xsi:type="array">
      <item name="mycustomrows" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="label" xsi:type="string" translate="true">My Custom Rows</item>
      </item>
      </item>
      </argument>
      <argument name="data" xsi:type="array">
      <item name="js_config" xsi:type="array">
      <item name="component" xsi:type="string">Magento_Ui/js/grid/provider</item>
      </item>
      </argument>
      </argument>
      <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>
      </argument>
      </dataSource>


      dataProvider for dataSource:



      <?php

      namespace MyVendorMyModuleModelCustomer;

      class DataProvider extends MagentoUiDataProviderAbstractDataProvider

      protected $loadedData;
      protected $collectionFactory;

      public function __construct(
      $name,
      $primaryFieldName,
      $requestFieldName,
      MyVendorMyModuleModelResourceModelRowCollection $collection,
      MyVendorMyModuleModelResourceModelRowCollectionFactory $collectionFactory,
      array $meta = [],
      array $data = []
      )
      $this->collection = $collection;
      $this->collectionFactory = $collectionFactory;

      parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);


      public function getData()

      if (isset($this->loadedData))
      return $this->loadedData;


      $collection = $this->collectionFactory->create();
      // add Filter for Customer ID
      //->setOrder('position', 'ASC');
      $items = $collection->getItems();

      foreach ($items as $item)
      $this->loadedData[$item->getId()] = $item->getData();


      return $this->loadedData;




      I believe the data has to be loaded with Plugin for "MagentoCustomerModelCustomerDataProvider" as I am doing below, but I can't seem to get populate rows on load.



      view/adminhtml/ui_component/customer_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">
      <fieldset name="mycustomrows">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="label" xsi:type="string" translate="true">My Custom Rows</item>
      <item name="sortOrder" xsi:type="number">10</item>
      </item>
      </argument>
      <dynamicRows name="mycustomrows">
      <settings>
      <addButtonLabel translate="true">Add Row</addButtonLabel>
      <additionalClasses>
      <class name="admin__field-wide">true</class>
      </additionalClasses>
      <componentType>dynamicRows</componentType>
      </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 name="positionProvider" xsi:type="string">position</item>
      </item>
      </argument>


      <field name="mycustomrows_select1" formElement="select" sortOrder="10">
      <settings>
      <dataType>text</dataType>
      <label translate="true">Select Field 1</label>
      <disabled>false</disabled>
      <dataScope>mycustomrows_select1</dataScope>
      </settings>
      <formElements>
      <select>
      <settings>
      <options class="MyVendorMyModuleModelSourceSelectFieldOne"/>
      </settings>
      </select>
      </formElements>
      </field>
      <field name="mycustomrows_input1" sortOrder="20" formElement="input">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="source" xsi:type="string">customer</item>
      </item>
      </argument>
      <settings>
      <label translate="true">Text Field 1</label>
      <dataType>text</dataType>
      <dataScope>mycustomrows_text1</dataScope>
      </settings>
      </field>
      <actionDelete sortOrder="30">
      <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="fit" xsi:type="boolean">false</item>
      <item name="label" xsi:type="string">Actions</item>
      <item name="sortOrder" xsi:type="string">500</item>
      <item name="additionalClasses" xsi:type="string">data-grid-actions-cell</item>
      <item name="template" xsi:type="string">Magento_Backend/dynamic-rows/cells/action-delete</item>
      </item>
      </argument>
      </actionDelete>
      </container>
      </dynamicRows>
      </fieldset>
      </form>


      etc/adminhtml/di.xml



      <?xml version="1.0"?>

      <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
      <type name="MagentoCustomerModelCustomerDataProvider">
      <plugin name="customer_get_mycustomrows" type="MyVendorMyModuleModelCustomerDataProvider" sortOrder="5" />
      </type>
      </config>


      Model/Customer/DataProvider.php



      <?php
      namespace MyVendorMyModuleModelCustomer;

      class DataProvider

      protected $collection;
      protected $collectionFactory;
      protected $loadedData;

      public function __construct(
      MyVendorMyModuleModelResourceModelRowCollection $collection,
      MyVendorMyModuleModelResourceModelRowCollectionFactory $collectionFactory,
      array $data = []
      )
      $this->collection = $collection;
      $this->collectionFactory = $collectionFactory;


      public function afterGetData(MagentoCustomerModelCustomerDataProvider $subject, $result)

      if($result)
      $customer_id = key($result);
      $customerData = $result[$customer_id]['customer'];

      if(is_null($this->loadedData))
      $this->loadedData = array();
      $collection = $this->collectionFactory->create(); //->setOrder('position', 'ASC');
      $items = $collection->getItems();

      foreach ($items as $item)
      $this->loadedData[] = $item->getData();



      $result[$customer_id]['customer']["mycustomrows"] = $this->loadedData;

      return $result;





      I can't seem to get any records populated when I load a customer edit page.









      share







      New contributor




      Cmaclean066 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      How can I load the data from customer DataProvider plugin into my ui_component dynamicRows?



      I have created a new tab in the admin customer edit form, and added my ui_component, which seems to work well. But I can't populate the data already stored in my database.



      I have tried to add xml for DataSource, but I think that has conflict with original customer_form.xml DataSource "customer_form.customer_form_data_source" because when I add DataSource, the page no longer loads.



      dataSource XML:



      <dataSource name="mycustomrows">
      <argument name="dataProvider" xsi:type="configurableObject">
      <argument name="class" xsi:type="string">MyVendorMyModuleModelCustomerDataProvider</argument>
      <argument name="primaryFieldName" xsi:type="string">id</argument>
      <argument name="requestFieldName" xsi:type="string">id</argument>
      <argument name="meta" xsi:type="array">
      <item name="mycustomrows" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="label" xsi:type="string" translate="true">My Custom Rows</item>
      </item>
      </item>
      </argument>
      <argument name="data" xsi:type="array">
      <item name="js_config" xsi:type="array">
      <item name="component" xsi:type="string">Magento_Ui/js/grid/provider</item>
      </item>
      </argument>
      </argument>
      <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>
      </argument>
      </dataSource>


      dataProvider for dataSource:



      <?php

      namespace MyVendorMyModuleModelCustomer;

      class DataProvider extends MagentoUiDataProviderAbstractDataProvider

      protected $loadedData;
      protected $collectionFactory;

      public function __construct(
      $name,
      $primaryFieldName,
      $requestFieldName,
      MyVendorMyModuleModelResourceModelRowCollection $collection,
      MyVendorMyModuleModelResourceModelRowCollectionFactory $collectionFactory,
      array $meta = [],
      array $data = []
      )
      $this->collection = $collection;
      $this->collectionFactory = $collectionFactory;

      parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);


      public function getData()

      if (isset($this->loadedData))
      return $this->loadedData;


      $collection = $this->collectionFactory->create();
      // add Filter for Customer ID
      //->setOrder('position', 'ASC');
      $items = $collection->getItems();

      foreach ($items as $item)
      $this->loadedData[$item->getId()] = $item->getData();


      return $this->loadedData;




      I believe the data has to be loaded with Plugin for "MagentoCustomerModelCustomerDataProvider" as I am doing below, but I can't seem to get populate rows on load.



      view/adminhtml/ui_component/customer_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">
      <fieldset name="mycustomrows">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="label" xsi:type="string" translate="true">My Custom Rows</item>
      <item name="sortOrder" xsi:type="number">10</item>
      </item>
      </argument>
      <dynamicRows name="mycustomrows">
      <settings>
      <addButtonLabel translate="true">Add Row</addButtonLabel>
      <additionalClasses>
      <class name="admin__field-wide">true</class>
      </additionalClasses>
      <componentType>dynamicRows</componentType>
      </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 name="positionProvider" xsi:type="string">position</item>
      </item>
      </argument>


      <field name="mycustomrows_select1" formElement="select" sortOrder="10">
      <settings>
      <dataType>text</dataType>
      <label translate="true">Select Field 1</label>
      <disabled>false</disabled>
      <dataScope>mycustomrows_select1</dataScope>
      </settings>
      <formElements>
      <select>
      <settings>
      <options class="MyVendorMyModuleModelSourceSelectFieldOne"/>
      </settings>
      </select>
      </formElements>
      </field>
      <field name="mycustomrows_input1" sortOrder="20" formElement="input">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="source" xsi:type="string">customer</item>
      </item>
      </argument>
      <settings>
      <label translate="true">Text Field 1</label>
      <dataType>text</dataType>
      <dataScope>mycustomrows_text1</dataScope>
      </settings>
      </field>
      <actionDelete sortOrder="30">
      <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="fit" xsi:type="boolean">false</item>
      <item name="label" xsi:type="string">Actions</item>
      <item name="sortOrder" xsi:type="string">500</item>
      <item name="additionalClasses" xsi:type="string">data-grid-actions-cell</item>
      <item name="template" xsi:type="string">Magento_Backend/dynamic-rows/cells/action-delete</item>
      </item>
      </argument>
      </actionDelete>
      </container>
      </dynamicRows>
      </fieldset>
      </form>


      etc/adminhtml/di.xml



      <?xml version="1.0"?>

      <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
      <type name="MagentoCustomerModelCustomerDataProvider">
      <plugin name="customer_get_mycustomrows" type="MyVendorMyModuleModelCustomerDataProvider" sortOrder="5" />
      </type>
      </config>


      Model/Customer/DataProvider.php



      <?php
      namespace MyVendorMyModuleModelCustomer;

      class DataProvider

      protected $collection;
      protected $collectionFactory;
      protected $loadedData;

      public function __construct(
      MyVendorMyModuleModelResourceModelRowCollection $collection,
      MyVendorMyModuleModelResourceModelRowCollectionFactory $collectionFactory,
      array $data = []
      )
      $this->collection = $collection;
      $this->collectionFactory = $collectionFactory;


      public function afterGetData(MagentoCustomerModelCustomerDataProvider $subject, $result)

      if($result)
      $customer_id = key($result);
      $customerData = $result[$customer_id]['customer'];

      if(is_null($this->loadedData))
      $this->loadedData = array();
      $collection = $this->collectionFactory->create(); //->setOrder('position', 'ASC');
      $items = $collection->getItems();

      foreach ($items as $item)
      $this->loadedData[] = $item->getData();



      $result[$customer_id]['customer']["mycustomrows"] = $this->loadedData;

      return $result;





      I can't seem to get any records populated when I load a customer edit page.







      magento2 customer-account dynamic-rows





      share







      New contributor




      Cmaclean066 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.










      share







      New contributor




      Cmaclean066 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      share



      share






      New contributor




      Cmaclean066 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 4 mins ago









      Cmaclean066Cmaclean066

      11




      11




      New contributor




      Cmaclean066 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Cmaclean066 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Cmaclean066 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















          0






          active

          oldest

          votes












          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "479"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );






          Cmaclean066 is a new contributor. Be nice, and check out our Code of Conduct.









          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f272700%2fmagento-2-dynamicrows-as-new-tab-for-admin-customer-edit-how-do-you-get-data-lo%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          Cmaclean066 is a new contributor. Be nice, and check out our Code of Conduct.









          draft saved

          draft discarded


















          Cmaclean066 is a new contributor. Be nice, and check out our Code of Conduct.












          Cmaclean066 is a new contributor. Be nice, and check out our Code of Conduct.











          Cmaclean066 is a new contributor. Be nice, and check out our Code of Conduct.














          Thanks for contributing an answer to Magento Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f272700%2fmagento-2-dynamicrows-as-new-tab-for-admin-customer-edit-how-do-you-get-data-lo%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Тонконіг бульбистий Зміст Опис | Поширення | Екологія | Господарське значення | Примітки | Див. також | Література | Джерела | Посилання | Навігаційне меню1114601320038-241116202404kew-435458Poa bulbosaЭлектронный каталог сосудистых растений Азиатской России [Електронний каталог судинних рослин Азіатської Росії]Малышев Л. Л. Дикие родичи культурных растений. Poa bulbosa L. - Мятлик луковичный. [Малишев Л. Л. Дикі родичи культурних рослин. Poa bulbosa L. - Тонконіг бульбистий.]Мятлик (POA) Сем. Злаки (Мятликовые) [Тонконіг (POA) Род. Злаки (Тонконогові)]Poa bulbosa Linnaeus, Sp. Pl. 1: 70. 1753. 鳞茎早熟禾 lin jing zao shu he (Description from Flora of China) [Poa bulbosa Linnaeus, Sp. Pl. 1: 70. 1753. 鳞茎早熟禾 lin jing zao shu he (Опис від Флора Китаю)]Poa bulbosa L. – lipnice cibulkatá / lipnica cibulkatáPoa bulbosa в базі даних Poa bulbosa на сайті Poa bulbosa в базі даних «Global Biodiversity Information Facility» (GBIF)Poa bulbosa в базі даних «Euro + Med PlantBase» — інформаційному ресурсі для Євро-середземноморського розмаїття рослинPoa bulbosa L. на сайті «Плантариум»

          Лель (журнал) Зміст Історія | Редакція | Автори і рубрики | Інтерв'ю, статті, рецензії | Див. також | Посилання | Навігаційне менюперевірена1 змінаСергій Чирков: «Плейбой» і «Пентхауз» у кіосках з'явилися вже після того, як зник «Лель»«Лель», підшивка 10 номерів (1992, 1993)Ніч з «Другом Читача»: казки на ніч для дорослихІнформація про журнал на сервері журналістів у ВР УкраїниНаталія Патрікєєва. Лель. Перший український еротичний журналр

          Best approach to update all entries in a list that is paginated?Best way to add items to a paginated listChoose Your Country: Best Usability approachUpdate list when a user is viewing the list without annoying themWhen would the best day to update your webpage be?What should happen when I add a Row to a paginated, sorted listShould I adopt infinite scrolling or classical pagination?How to show user that page objects automatically updateWhat is the best location to locate the comments section in a list pageBest way to combine filtering and selecting items in a listWhen one of two inputs must be updated to satisfy a consistency criteria, which should you update (if at all)?