title: Magento 2 dynamicRows as new tab for admin customer edit, how do you get data loaded?
body: <p>How can I load the data from customer DataProvider plugin into my ui_component dynamicRows? </p>
  
  <p>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. </p>
  
  <p>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. </p>
  
  <p>dataSource XML:</p>
  
  <pre><code>&lt;dataSource name="mycustomrows"&gt;
      &lt;argument name="dataProvider" xsi:type="configurableObject"&gt;
          &lt;argument name="class" xsi:type="string"&gt;MyVendor\MyModule\Model\Customer\DataProvider&lt;/argument&gt;
          &lt;argument name="primaryFieldName" xsi:type="string"&gt;id&lt;/argument&gt;
          &lt;argument name="requestFieldName" xsi:type="string"&gt;id&lt;/argument&gt;
          &lt;argument name="meta" xsi:type="array"&gt;
              &lt;item name="myshipping" xsi:type="array"&gt;
                  &lt;item name="config" xsi:type="array"&gt;
                      &lt;item name="label" xsi:type="string" translate="true"&gt;My Custom Rows&lt;/item&gt;
                  &lt;/item&gt;
              &lt;/item&gt;
          &lt;/argument&gt;
          &lt;argument name="data" xsi:type="array"&gt;
              &lt;item name="js_config" xsi:type="array"&gt;
                  &lt;item name="component" xsi:type="string"&gt;Magento_Ui/js/grid/provider&lt;/item&gt;
              &lt;/item&gt;
          &lt;/argument&gt;
      &lt;/argument&gt;
      &lt;argument name="data" xsi:type="array"&gt;
          &lt;item name="js_config" xsi:type="array"&gt;
              &lt;item name="component" xsi:type="string"&gt;Magento_Ui/js/form/provider&lt;/item&gt;
          &lt;/item&gt;
      &lt;/argument&gt;
  &lt;/dataSource&gt;
  </code></pre>
  
  <p>dataProvider for dataSource:</p>
  
  <pre><code>&lt;?php
  
  namespace MyVendor\MyModule\Model\Customer;
  
  class DataProvider extends \Magento\Ui\DataProvider\AbstractDataProvider
  {
     protected $loadedData;
     protected $collectionFactory;
  
     public function __construct(
         $name,
         $primaryFieldName,
         $requestFieldName,
         \MyVendor\MyModule\Model\ResourceModel\Row\Collection $collection,
         \MyVendor\MyModule\Model\ResourceModel\Row\CollectionFactory $collectionFactory,
         array $meta = [],
         array $data = []
     ) {
         $this-&gt;collection = $collection;
         $this-&gt;collectionFactory = $collectionFactory;
  
         parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
     }
  
     public function getData()
     {
         if (isset($this-&gt;loadedData)) {
             return $this-&gt;loadedData;
         }
  
         $collection = $this-&gt;collectionFactory-&gt;create(); 
         // add Filter for Customer ID
         //-&gt;setOrder('position', 'ASC');
         $items = $collection-&gt;getItems();
  
         foreach ($items as $item) {
             $this-&gt;loadedData[$item-&gt;getId()] = $item-&gt;getData();
         }
  
         return $this-&gt;loadedData;
     }
  }
  </code></pre>
  
  <p>I believe the data has to be loaded with Plugin for "Magento\Customer\Model\Customer\DataProvider" as I am doing below, but I can't seem to get populate rows on load. </p>
  
  <p>view/adminhtml/ui_component/customer_form.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd"&gt;
      &lt;fieldset name="mycustomrows"&gt;
          &lt;argument name="data" xsi:type="array"&gt;
              &lt;item name="config" xsi:type="array"&gt;
                  &lt;item name="label" xsi:type="string" translate="true"&gt;My Custom Rows&lt;/item&gt;
                  &lt;item name="sortOrder" xsi:type="number"&gt;10&lt;/item&gt;
              &lt;/item&gt;
          &lt;/argument&gt;
          &lt;dynamicRows name="mycustomrows"&gt;
              &lt;settings&gt;
                  &lt;addButtonLabel translate="true"&gt;Add Row&lt;/addButtonLabel&gt;
                  &lt;additionalClasses&gt;
                      &lt;class name="admin__field-wide"&gt;true&lt;/class&gt;
                  &lt;/additionalClasses&gt;
                  &lt;componentType&gt;dynamicRows&lt;/componentType&gt;
              &lt;/settings&gt;
  
              &lt;container name="record" component="Magento_Ui/js/dynamic-rows/record"&gt;
                  &lt;argument name="data" xsi:type="array"&gt;
                      &lt;item name="config" xsi:type="array"&gt;
                          &lt;item name="isTemplate" xsi:type="boolean"&gt;true&lt;/item&gt;
                          &lt;item name="is_collection" xsi:type="boolean"&gt;true&lt;/item&gt;
                          &lt;item name="componentType" xsi:type="string"&gt;container&lt;/item&gt;
                          &lt;item name="positionProvider" xsi:type="string"&gt;position&lt;/item&gt;
                      &lt;/item&gt;
                  &lt;/argument&gt;
  
  
                  &lt;field name="mycustomrows_select1" formElement="select" sortOrder="10"&gt;
                      &lt;settings&gt;
                          &lt;dataType&gt;text&lt;/dataType&gt;
                          &lt;label translate="true"&gt;Select Field 1&lt;/label&gt;
                          &lt;disabled&gt;false&lt;/disabled&gt;
                          &lt;dataScope&gt;mycustomrows_select1&lt;/dataScope&gt;
                      &lt;/settings&gt;
                      &lt;formElements&gt;
                          &lt;select&gt;
                              &lt;settings&gt;
                                  &lt;options class="MyVendor\MyModule\Model\Source\SelectFieldOne"/&gt;
                              &lt;/settings&gt;
                          &lt;/select&gt;
                      &lt;/formElements&gt;
                  &lt;/field&gt;
                  &lt;field name="mycustomrows_input1" sortOrder="20" formElement="input"&gt;
                      &lt;argument name="data" xsi:type="array"&gt;
                          &lt;item name="config" xsi:type="array"&gt;
                              &lt;item name="source" xsi:type="string"&gt;customer&lt;/item&gt;
                          &lt;/item&gt;
                      &lt;/argument&gt;
                      &lt;settings&gt;
                          &lt;label translate="true"&gt;Text Field 1&lt;/label&gt;
                          &lt;dataType&gt;text&lt;/dataType&gt;
                          &lt;dataScope&gt;mycustomrows_text1&lt;/dataScope&gt;
                      &lt;/settings&gt;
                  &lt;/field&gt;
                  &lt;actionDelete sortOrder="30"&gt;
                      &lt;argument name="data" xsi:type="array"&gt;
                          &lt;item name="config" xsi:type="array"&gt;
                              &lt;item name="componentType" xsi:type="string"&gt;actionDelete&lt;/item&gt;
                              &lt;item name="dataType" xsi:type="string"&gt;text&lt;/item&gt;
                              &lt;item name="fit" xsi:type="boolean"&gt;false&lt;/item&gt;
                              &lt;item name="label" xsi:type="string"&gt;Actions&lt;/item&gt;
                              &lt;item name="sortOrder" xsi:type="string"&gt;500&lt;/item&gt;
                              &lt;item name="additionalClasses" xsi:type="string"&gt;data-grid-actions-cell&lt;/item&gt;
                              &lt;item name="template" xsi:type="string"&gt;Magento_Backend/dynamic-rows/cells/action-delete&lt;/item&gt;
                          &lt;/item&gt;
                      &lt;/argument&gt;
                  &lt;/actionDelete&gt;
              &lt;/container&gt;
          &lt;/dynamicRows&gt;
      &lt;/fieldset&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>etc/adminhtml/di.xml</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  
  &lt;config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"&gt;
      &lt;type name="Magento\Customer\Model\Customer\DataProvider"&gt;
          &lt;plugin name="customer_get_mycustomrows" type="MyVendor\MyModule\Model\Customer\DataProvider" sortOrder="5" /&gt;
      &lt;/type&gt;
  &lt;/config&gt;
  </code></pre>
  
  <p>Model/Customer/DataProvider.php</p>
  
  <pre><code>&lt;?php
  namespace MyVendor\MyModule\Model\Customer;
  
  class DataProvider 
  {
      protected $collection;
      protected $collectionFactory;
      protected $loadedData;
  
      public function __construct(
          \MyVendor\MyModule\Model\ResourceModel\Row\Collection $collection,
          \MyVendor\MyModule\Model\ResourceModel\Row\CollectionFactory $collectionFactory,
          array $data = []
      ) {
          $this-&gt;collection = $collection;
          $this-&gt;collectionFactory = $collectionFactory;
      }
  
      public function afterGetData(\Magento\Customer\Model\Customer\DataProvider $subject, $result)
      {
          if($result){
              $customer_id = key($result);
              $customerData =  $result[$customer_id]['customer'];
  
              if(is_null($this-&gt;loadedData)) {
                  $this-&gt;loadedData = array();
                  $collection = $this-&gt;collectionFactory-&gt;create(); //-&gt;setOrder('position', 'ASC');
                  $items = $collection-&gt;getItems();
  
                  foreach ($items as $item) {
                      $this-&gt;loadedData[] = $item-&gt;getData();
                  }
              }
  
              $result[$customer_id]['customer']["mycustomrows"] = $this-&gt;loadedData;
          }
          return $result;
      }
  
  }
  </code></pre>
  
  <p>I can't seem to get any records populated when I load a customer edit page.</p>