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

          Magento 2 duplicate PHPSESSID cookie when using session_start() in custom php scriptMagento 2: User cant logged in into to account page, no error showing!Magento duplicate on subdomainGrabbing storeview from cookie (after using language selector)How do I run php custom script on magento2Magento 2: Include PHP script in headerSession lock after using Cm_RedisSessionscript php to update stockMagento set cookie popupMagento 2 session id cookie - where to find it?How to import Configurable product from csv with custom attributes using php scriptMagento 2 run custom PHP script

          Can not update quote_id field of “quote_item” table magento 2Magento 2.1 - We can't remove the item. (Shopping Cart doesnt allow us to remove items before becomes empty)Add value for custom quote item attribute using REST apiREST API endpoint v1/carts/cartId/items always returns error messageCorrect way to save entries to databaseHow to remove all associated quote objects of a customer completelyMagento 2 - Save value from custom input field to quote_itemGet quote_item data using quote id and product id filter in Magento 2How to set additional data to quote_item table from controller in Magento 2?What is the purpose of additional_data column in quote_item table in magento2Set Custom Price to Quote item magento2 from controller

          How to solve knockout JS error in Magento 2 Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?(Magento2) knockout.js:3012 Uncaught ReferenceError: Unable to process bindingUnable to process binding Knockout.js magento 2Cannot read property `scopeLabel` of undefined on Product Detail PageCan't get Customer Data on frontend in Magento 2Magento2 Order Summary - unable to process bindingKO templates are not loading in Magento 2.1 applicationgetting knockout js error magento 2Product grid not load -— Unable to process binding Knockout.js magento 2Product form not loaded in magento2Uncaught ReferenceError: Unable to process binding “if: function()return (isShowLegend()) ” magento 2