Add Custom Product Form Custom Data Source Without Overriding Product Data SourceData population in UI formuiComponent Form. How to show data from DB tablemagento 2 simple admin form with submit and without any data sourceMagento 2 Add new field to Magento_User admin formMagento 2 UI Form without collectionMagento 2. Use ui form component without a data sourcedata-source-for-selected-admin-ui-formCustom Field in Product Edit form in magento2 adminMagento 2.3.0 While edit UI component form data not filled up in custom moduleHow To Add Custom Data Into Product Edit Form DynamicRows Ui Component

What is the relationship between spectral sequences and obstruction theory?

Why does nature favour the Laplacian?

Using a Lyapunov function to classify stability and sketching a phase portrait

Combinable filters

Contradiction proof for inequality of P and NP?

Please, smoke with good manners

How to solve constants out of the internal energy equation?

How can I practically buy stocks?

How can Republicans who favour free markets, consistently express anger when they don't like the outcome of that choice?

What are the potential pitfalls when using metals as a currency?

How much cash can I safely carry into the USA and avoid civil forfeiture?

Rivers without rain

How can the Zone of Truth spell be defeated without the caster knowing?

How exactly does Hawking radiation decrease the mass of black holes?

Does a semiconductor follow Ohm's law?

Why does processed meat contain preservatives, while canned fish needs not?

How could Tony Stark make this in Endgame?

Why is it that the natural deduction method can't test for invalidity?

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

How come there are so many candidates for the 2020 Democratic party presidential nomination?

Who is the Umpire in this picture?

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

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

Will a top journal at least read my introduction?



Add Custom Product Form Custom Data Source Without Overriding Product Data Source


Data population in UI formuiComponent Form. How to show data from DB tablemagento 2 simple admin form with submit and without any data sourceMagento 2 Add new field to Magento_User admin formMagento 2 UI Form without collectionMagento 2. Use ui form component without a data sourcedata-source-for-selected-admin-ui-formCustom Field in Product Edit form in magento2 adminMagento 2.3.0 While edit UI component form data not filled up in custom moduleHow To Add Custom Data Into Product Edit Form DynamicRows Ui Component






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








0















I've added a dynamic rows element which is populated from a custom table. This is working fine but the datasource for this ui component overrides the default product data source and the default product form fields are not being populated. I've added my datasource like this:



class DataProvider extends MagentoUiDataProviderAbstractDataProvider

/**
* @param string $name
* @param string $primaryFieldName
* @param string $requestFieldName
* @param CollectionFactory $customerGroupsPricesCollectionFactory
* @param array $meta
* @param array $data
*/
public function __construct(
$name,
$primaryFieldName,
$requestFieldName,
CollectionFactory $customerGroupsPricesCollectionFactory,
array $meta = [],
array $data = []
)
$this->collection = $customerGroupsPricesCollectionFactory->create();
parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);


public function getData()

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


$items = $this->collection->getItems();
$this->loadedData = array();

/** @var CustomerGroupsPrice $customerGroupsPrice */
foreach ($items as $customerGroupsPrice)
$this->loadedData[$customerGroupsPrice->getProductId()]['customer_groups_price_container'][] = $customerGroupsPrice->getData();

//var_dump($this->loadedData);exit;
return $this->loadedData;





and my product_form.xml



<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<argument name="data" xsi:type="array">
<item name="js_config" xsi:type="array">
<item name="provider" xsi:type="string">product_form.customer_groups_prices_data_source</item>
<item name="deps" xsi:type="string">product_form.customer_groups_prices_data_source</item>
</item>
<item name="config" xsi:type="array">
<item name="dataScope" xsi:type="string">data</item>
<item name="namespace" xsi:type="string">product_form</item>
</item>
</argument>

<settings>
<namespace>product_form</namespace>
<dataScope>data</dataScope>
<deps>
<dep>product_form.customer_groups_prices_data_source</dep>
</deps>
</settings>

<dataSource name="customer_groups_prices_data_source">
<argument name="dataProvider" xsi:type="configurableObject">
<argument name="class" xsi:type="string">VendorModuleModelDataProvider</argument>
<argument name="name" xsi:type="string">customer_groups_prices_data_source</argument>
<argument name="primaryFieldName" xsi:type="string">product_id</argument>
<argument name="requestFieldName" xsi:type="string">id</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>
</argument>
</dataSource>

<fieldset name="customer_groups_price_set">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="label" xsi:type="string" translate="true">Customer Group Special Prices</item>
<item name="sortOrder" xsi:type="number">10</item>
</item>
</argument>
<container name="customer_groups_price_container">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="component" xsi:type="string">Magento_Ui/js/dynamic-rows/dynamic-rows</item>
<item name="template" xsi:type="string">ui/dynamic-rows/templates/default</item>
<item name="componentType" xsi:type="string">dynamicRows</item>
<item name="recordTemplate" xsi:type="string">record</item>
<item name="addButtonLabel" xsi:type="string">Add Row</item>
<item name="deleteProperty" xsi:type="boolean">false</item>
</item>
</argument>

<container name="record">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="label" xsi:type="string" translate="true">Group Special Price</item>
<item name="component" xsi:type="string" translate="true">Magento_Ui/js/dynamic-rows/record</item>
<item name="isTemplate" xsi:type="boolean">true</item>
<item name="is_collection" xsi:type="boolean">true</item>
<item name="showFallbackReset" xsi:type="boolean">false</item>
<item name="source" xsi:type="string">customer_groups_price_container</item>
</item>
</argument>
<field name="entity_id">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="visible" xsi:type="boolean">false</item>
<item name="dataType" xsi:type="string">text</item>
<item name="formElement" xsi:type="string">input</item>
<item name="source" xsi:type="string">customer_groups_price_container</item>
<item name="dataScope" xsi:type="string">entity_id</item>
<item name="required" xsi:type="boolean">true</item>
</item>
</argument>
</field>

<field name="product_id">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="visible" xsi:type="boolean">false</item>
<item name="dataType" xsi:type="string">text</item>
<item name="formElement" xsi:type="string">input</item>
<item name="source" xsi:type="string">customer_groups_price_container</item>
<item name="dataScope" xsi:type="string">product_id</item>
<item name="required" xsi:type="boolean">true</item>
</item>
</argument>
</field>

<field name="website_id">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="label" xsi:type="string">Website ID</item>
<item name="visible" xsi:type="boolean">true</item>
<item name="dataType" xsi:type="string">text</item>
<item name="formElement" xsi:type="string">input</item>
<item name="source" xsi:type="string">customer_groups_price_container</item>
<item name="dataScope" xsi:type="string">website_id</item>
<item name="required" xsi:type="boolean">true</item>
</item>
</argument>
</field>

<field name="customer_group_id">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="label" xsi:type="string">Customer Group</item>
<item name="visible" xsi:type="boolean">true</item>
<item name="dataType" xsi:type="string">text</item>
<item name="formElement" xsi:type="string">select</item>
<item name="source" xsi:type="string">customer_groups_price_container</item>
<item name="dataScope" xsi:type="string">customer_group_id</item>
<item name="required" xsi:type="boolean">true</item>
</item>
<item name="options" xsi:type="object">MagentoCatalogRuleModelRuleCustomerGroupsOptionsProvider</item>
</argument>
</field>

<field name="price">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="label" xsi:type="string">Special Price</item>
<item name="visible" xsi:type="boolean">true</item>
<item name="dataType" xsi:type="string">text</item>
<item name="formElement" xsi:type="string">input</item>
<item name="source" xsi:type="string">customer_groups_price_container</item>
<item name="dataScope" xsi:type="string">price</item>
<item name="required" xsi:type="boolean">true</item>
</item>
</argument>
</field>
</container>
</container>
</fieldset>




The custom form fieldset renders as expected:
enter image description here



but the rest of the product data is not loaded. I can see from inspecting using DevTools in Chrome that the data model for the product is loaded and all product data is there:
enter image description here
it just isn't populating in the form fields when I add my custom datasource. Can anyone help me add the custom datasource without losing the rest of the product data please?










share|improve this question




























    0















    I've added a dynamic rows element which is populated from a custom table. This is working fine but the datasource for this ui component overrides the default product data source and the default product form fields are not being populated. I've added my datasource like this:



    class DataProvider extends MagentoUiDataProviderAbstractDataProvider

    /**
    * @param string $name
    * @param string $primaryFieldName
    * @param string $requestFieldName
    * @param CollectionFactory $customerGroupsPricesCollectionFactory
    * @param array $meta
    * @param array $data
    */
    public function __construct(
    $name,
    $primaryFieldName,
    $requestFieldName,
    CollectionFactory $customerGroupsPricesCollectionFactory,
    array $meta = [],
    array $data = []
    )
    $this->collection = $customerGroupsPricesCollectionFactory->create();
    parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);


    public function getData()

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


    $items = $this->collection->getItems();
    $this->loadedData = array();

    /** @var CustomerGroupsPrice $customerGroupsPrice */
    foreach ($items as $customerGroupsPrice)
    $this->loadedData[$customerGroupsPrice->getProductId()]['customer_groups_price_container'][] = $customerGroupsPrice->getData();

    //var_dump($this->loadedData);exit;
    return $this->loadedData;





    and my product_form.xml



    <form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <argument name="data" xsi:type="array">
    <item name="js_config" xsi:type="array">
    <item name="provider" xsi:type="string">product_form.customer_groups_prices_data_source</item>
    <item name="deps" xsi:type="string">product_form.customer_groups_prices_data_source</item>
    </item>
    <item name="config" xsi:type="array">
    <item name="dataScope" xsi:type="string">data</item>
    <item name="namespace" xsi:type="string">product_form</item>
    </item>
    </argument>

    <settings>
    <namespace>product_form</namespace>
    <dataScope>data</dataScope>
    <deps>
    <dep>product_form.customer_groups_prices_data_source</dep>
    </deps>
    </settings>

    <dataSource name="customer_groups_prices_data_source">
    <argument name="dataProvider" xsi:type="configurableObject">
    <argument name="class" xsi:type="string">VendorModuleModelDataProvider</argument>
    <argument name="name" xsi:type="string">customer_groups_prices_data_source</argument>
    <argument name="primaryFieldName" xsi:type="string">product_id</argument>
    <argument name="requestFieldName" xsi:type="string">id</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>
    </argument>
    </dataSource>

    <fieldset name="customer_groups_price_set">
    <argument name="data" xsi:type="array">
    <item name="config" xsi:type="array">
    <item name="label" xsi:type="string" translate="true">Customer Group Special Prices</item>
    <item name="sortOrder" xsi:type="number">10</item>
    </item>
    </argument>
    <container name="customer_groups_price_container">
    <argument name="data" xsi:type="array">
    <item name="config" xsi:type="array">
    <item name="component" xsi:type="string">Magento_Ui/js/dynamic-rows/dynamic-rows</item>
    <item name="template" xsi:type="string">ui/dynamic-rows/templates/default</item>
    <item name="componentType" xsi:type="string">dynamicRows</item>
    <item name="recordTemplate" xsi:type="string">record</item>
    <item name="addButtonLabel" xsi:type="string">Add Row</item>
    <item name="deleteProperty" xsi:type="boolean">false</item>
    </item>
    </argument>

    <container name="record">
    <argument name="data" xsi:type="array">
    <item name="config" xsi:type="array">
    <item name="label" xsi:type="string" translate="true">Group Special Price</item>
    <item name="component" xsi:type="string" translate="true">Magento_Ui/js/dynamic-rows/record</item>
    <item name="isTemplate" xsi:type="boolean">true</item>
    <item name="is_collection" xsi:type="boolean">true</item>
    <item name="showFallbackReset" xsi:type="boolean">false</item>
    <item name="source" xsi:type="string">customer_groups_price_container</item>
    </item>
    </argument>
    <field name="entity_id">
    <argument name="data" xsi:type="array">
    <item name="config" xsi:type="array">
    <item name="visible" xsi:type="boolean">false</item>
    <item name="dataType" xsi:type="string">text</item>
    <item name="formElement" xsi:type="string">input</item>
    <item name="source" xsi:type="string">customer_groups_price_container</item>
    <item name="dataScope" xsi:type="string">entity_id</item>
    <item name="required" xsi:type="boolean">true</item>
    </item>
    </argument>
    </field>

    <field name="product_id">
    <argument name="data" xsi:type="array">
    <item name="config" xsi:type="array">
    <item name="visible" xsi:type="boolean">false</item>
    <item name="dataType" xsi:type="string">text</item>
    <item name="formElement" xsi:type="string">input</item>
    <item name="source" xsi:type="string">customer_groups_price_container</item>
    <item name="dataScope" xsi:type="string">product_id</item>
    <item name="required" xsi:type="boolean">true</item>
    </item>
    </argument>
    </field>

    <field name="website_id">
    <argument name="data" xsi:type="array">
    <item name="config" xsi:type="array">
    <item name="label" xsi:type="string">Website ID</item>
    <item name="visible" xsi:type="boolean">true</item>
    <item name="dataType" xsi:type="string">text</item>
    <item name="formElement" xsi:type="string">input</item>
    <item name="source" xsi:type="string">customer_groups_price_container</item>
    <item name="dataScope" xsi:type="string">website_id</item>
    <item name="required" xsi:type="boolean">true</item>
    </item>
    </argument>
    </field>

    <field name="customer_group_id">
    <argument name="data" xsi:type="array">
    <item name="config" xsi:type="array">
    <item name="label" xsi:type="string">Customer Group</item>
    <item name="visible" xsi:type="boolean">true</item>
    <item name="dataType" xsi:type="string">text</item>
    <item name="formElement" xsi:type="string">select</item>
    <item name="source" xsi:type="string">customer_groups_price_container</item>
    <item name="dataScope" xsi:type="string">customer_group_id</item>
    <item name="required" xsi:type="boolean">true</item>
    </item>
    <item name="options" xsi:type="object">MagentoCatalogRuleModelRuleCustomerGroupsOptionsProvider</item>
    </argument>
    </field>

    <field name="price">
    <argument name="data" xsi:type="array">
    <item name="config" xsi:type="array">
    <item name="label" xsi:type="string">Special Price</item>
    <item name="visible" xsi:type="boolean">true</item>
    <item name="dataType" xsi:type="string">text</item>
    <item name="formElement" xsi:type="string">input</item>
    <item name="source" xsi:type="string">customer_groups_price_container</item>
    <item name="dataScope" xsi:type="string">price</item>
    <item name="required" xsi:type="boolean">true</item>
    </item>
    </argument>
    </field>
    </container>
    </container>
    </fieldset>




    The custom form fieldset renders as expected:
    enter image description here



    but the rest of the product data is not loaded. I can see from inspecting using DevTools in Chrome that the data model for the product is loaded and all product data is there:
    enter image description here
    it just isn't populating in the form fields when I add my custom datasource. Can anyone help me add the custom datasource without losing the rest of the product data please?










    share|improve this question
























      0












      0








      0








      I've added a dynamic rows element which is populated from a custom table. This is working fine but the datasource for this ui component overrides the default product data source and the default product form fields are not being populated. I've added my datasource like this:



      class DataProvider extends MagentoUiDataProviderAbstractDataProvider

      /**
      * @param string $name
      * @param string $primaryFieldName
      * @param string $requestFieldName
      * @param CollectionFactory $customerGroupsPricesCollectionFactory
      * @param array $meta
      * @param array $data
      */
      public function __construct(
      $name,
      $primaryFieldName,
      $requestFieldName,
      CollectionFactory $customerGroupsPricesCollectionFactory,
      array $meta = [],
      array $data = []
      )
      $this->collection = $customerGroupsPricesCollectionFactory->create();
      parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);


      public function getData()

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


      $items = $this->collection->getItems();
      $this->loadedData = array();

      /** @var CustomerGroupsPrice $customerGroupsPrice */
      foreach ($items as $customerGroupsPrice)
      $this->loadedData[$customerGroupsPrice->getProductId()]['customer_groups_price_container'][] = $customerGroupsPrice->getData();

      //var_dump($this->loadedData);exit;
      return $this->loadedData;





      and my product_form.xml



      <form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
      <argument name="data" xsi:type="array">
      <item name="js_config" xsi:type="array">
      <item name="provider" xsi:type="string">product_form.customer_groups_prices_data_source</item>
      <item name="deps" xsi:type="string">product_form.customer_groups_prices_data_source</item>
      </item>
      <item name="config" xsi:type="array">
      <item name="dataScope" xsi:type="string">data</item>
      <item name="namespace" xsi:type="string">product_form</item>
      </item>
      </argument>

      <settings>
      <namespace>product_form</namespace>
      <dataScope>data</dataScope>
      <deps>
      <dep>product_form.customer_groups_prices_data_source</dep>
      </deps>
      </settings>

      <dataSource name="customer_groups_prices_data_source">
      <argument name="dataProvider" xsi:type="configurableObject">
      <argument name="class" xsi:type="string">VendorModuleModelDataProvider</argument>
      <argument name="name" xsi:type="string">customer_groups_prices_data_source</argument>
      <argument name="primaryFieldName" xsi:type="string">product_id</argument>
      <argument name="requestFieldName" xsi:type="string">id</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>
      </argument>
      </dataSource>

      <fieldset name="customer_groups_price_set">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="label" xsi:type="string" translate="true">Customer Group Special Prices</item>
      <item name="sortOrder" xsi:type="number">10</item>
      </item>
      </argument>
      <container name="customer_groups_price_container">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="component" xsi:type="string">Magento_Ui/js/dynamic-rows/dynamic-rows</item>
      <item name="template" xsi:type="string">ui/dynamic-rows/templates/default</item>
      <item name="componentType" xsi:type="string">dynamicRows</item>
      <item name="recordTemplate" xsi:type="string">record</item>
      <item name="addButtonLabel" xsi:type="string">Add Row</item>
      <item name="deleteProperty" xsi:type="boolean">false</item>
      </item>
      </argument>

      <container name="record">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="label" xsi:type="string" translate="true">Group Special Price</item>
      <item name="component" xsi:type="string" translate="true">Magento_Ui/js/dynamic-rows/record</item>
      <item name="isTemplate" xsi:type="boolean">true</item>
      <item name="is_collection" xsi:type="boolean">true</item>
      <item name="showFallbackReset" xsi:type="boolean">false</item>
      <item name="source" xsi:type="string">customer_groups_price_container</item>
      </item>
      </argument>
      <field name="entity_id">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="visible" xsi:type="boolean">false</item>
      <item name="dataType" xsi:type="string">text</item>
      <item name="formElement" xsi:type="string">input</item>
      <item name="source" xsi:type="string">customer_groups_price_container</item>
      <item name="dataScope" xsi:type="string">entity_id</item>
      <item name="required" xsi:type="boolean">true</item>
      </item>
      </argument>
      </field>

      <field name="product_id">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="visible" xsi:type="boolean">false</item>
      <item name="dataType" xsi:type="string">text</item>
      <item name="formElement" xsi:type="string">input</item>
      <item name="source" xsi:type="string">customer_groups_price_container</item>
      <item name="dataScope" xsi:type="string">product_id</item>
      <item name="required" xsi:type="boolean">true</item>
      </item>
      </argument>
      </field>

      <field name="website_id">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="label" xsi:type="string">Website ID</item>
      <item name="visible" xsi:type="boolean">true</item>
      <item name="dataType" xsi:type="string">text</item>
      <item name="formElement" xsi:type="string">input</item>
      <item name="source" xsi:type="string">customer_groups_price_container</item>
      <item name="dataScope" xsi:type="string">website_id</item>
      <item name="required" xsi:type="boolean">true</item>
      </item>
      </argument>
      </field>

      <field name="customer_group_id">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="label" xsi:type="string">Customer Group</item>
      <item name="visible" xsi:type="boolean">true</item>
      <item name="dataType" xsi:type="string">text</item>
      <item name="formElement" xsi:type="string">select</item>
      <item name="source" xsi:type="string">customer_groups_price_container</item>
      <item name="dataScope" xsi:type="string">customer_group_id</item>
      <item name="required" xsi:type="boolean">true</item>
      </item>
      <item name="options" xsi:type="object">MagentoCatalogRuleModelRuleCustomerGroupsOptionsProvider</item>
      </argument>
      </field>

      <field name="price">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="label" xsi:type="string">Special Price</item>
      <item name="visible" xsi:type="boolean">true</item>
      <item name="dataType" xsi:type="string">text</item>
      <item name="formElement" xsi:type="string">input</item>
      <item name="source" xsi:type="string">customer_groups_price_container</item>
      <item name="dataScope" xsi:type="string">price</item>
      <item name="required" xsi:type="boolean">true</item>
      </item>
      </argument>
      </field>
      </container>
      </container>
      </fieldset>




      The custom form fieldset renders as expected:
      enter image description here



      but the rest of the product data is not loaded. I can see from inspecting using DevTools in Chrome that the data model for the product is loaded and all product data is there:
      enter image description here
      it just isn't populating in the form fields when I add my custom datasource. Can anyone help me add the custom datasource without losing the rest of the product data please?










      share|improve this question














      I've added a dynamic rows element which is populated from a custom table. This is working fine but the datasource for this ui component overrides the default product data source and the default product form fields are not being populated. I've added my datasource like this:



      class DataProvider extends MagentoUiDataProviderAbstractDataProvider

      /**
      * @param string $name
      * @param string $primaryFieldName
      * @param string $requestFieldName
      * @param CollectionFactory $customerGroupsPricesCollectionFactory
      * @param array $meta
      * @param array $data
      */
      public function __construct(
      $name,
      $primaryFieldName,
      $requestFieldName,
      CollectionFactory $customerGroupsPricesCollectionFactory,
      array $meta = [],
      array $data = []
      )
      $this->collection = $customerGroupsPricesCollectionFactory->create();
      parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);


      public function getData()

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


      $items = $this->collection->getItems();
      $this->loadedData = array();

      /** @var CustomerGroupsPrice $customerGroupsPrice */
      foreach ($items as $customerGroupsPrice)
      $this->loadedData[$customerGroupsPrice->getProductId()]['customer_groups_price_container'][] = $customerGroupsPrice->getData();

      //var_dump($this->loadedData);exit;
      return $this->loadedData;





      and my product_form.xml



      <form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
      <argument name="data" xsi:type="array">
      <item name="js_config" xsi:type="array">
      <item name="provider" xsi:type="string">product_form.customer_groups_prices_data_source</item>
      <item name="deps" xsi:type="string">product_form.customer_groups_prices_data_source</item>
      </item>
      <item name="config" xsi:type="array">
      <item name="dataScope" xsi:type="string">data</item>
      <item name="namespace" xsi:type="string">product_form</item>
      </item>
      </argument>

      <settings>
      <namespace>product_form</namespace>
      <dataScope>data</dataScope>
      <deps>
      <dep>product_form.customer_groups_prices_data_source</dep>
      </deps>
      </settings>

      <dataSource name="customer_groups_prices_data_source">
      <argument name="dataProvider" xsi:type="configurableObject">
      <argument name="class" xsi:type="string">VendorModuleModelDataProvider</argument>
      <argument name="name" xsi:type="string">customer_groups_prices_data_source</argument>
      <argument name="primaryFieldName" xsi:type="string">product_id</argument>
      <argument name="requestFieldName" xsi:type="string">id</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>
      </argument>
      </dataSource>

      <fieldset name="customer_groups_price_set">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="label" xsi:type="string" translate="true">Customer Group Special Prices</item>
      <item name="sortOrder" xsi:type="number">10</item>
      </item>
      </argument>
      <container name="customer_groups_price_container">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="component" xsi:type="string">Magento_Ui/js/dynamic-rows/dynamic-rows</item>
      <item name="template" xsi:type="string">ui/dynamic-rows/templates/default</item>
      <item name="componentType" xsi:type="string">dynamicRows</item>
      <item name="recordTemplate" xsi:type="string">record</item>
      <item name="addButtonLabel" xsi:type="string">Add Row</item>
      <item name="deleteProperty" xsi:type="boolean">false</item>
      </item>
      </argument>

      <container name="record">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="label" xsi:type="string" translate="true">Group Special Price</item>
      <item name="component" xsi:type="string" translate="true">Magento_Ui/js/dynamic-rows/record</item>
      <item name="isTemplate" xsi:type="boolean">true</item>
      <item name="is_collection" xsi:type="boolean">true</item>
      <item name="showFallbackReset" xsi:type="boolean">false</item>
      <item name="source" xsi:type="string">customer_groups_price_container</item>
      </item>
      </argument>
      <field name="entity_id">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="visible" xsi:type="boolean">false</item>
      <item name="dataType" xsi:type="string">text</item>
      <item name="formElement" xsi:type="string">input</item>
      <item name="source" xsi:type="string">customer_groups_price_container</item>
      <item name="dataScope" xsi:type="string">entity_id</item>
      <item name="required" xsi:type="boolean">true</item>
      </item>
      </argument>
      </field>

      <field name="product_id">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="visible" xsi:type="boolean">false</item>
      <item name="dataType" xsi:type="string">text</item>
      <item name="formElement" xsi:type="string">input</item>
      <item name="source" xsi:type="string">customer_groups_price_container</item>
      <item name="dataScope" xsi:type="string">product_id</item>
      <item name="required" xsi:type="boolean">true</item>
      </item>
      </argument>
      </field>

      <field name="website_id">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="label" xsi:type="string">Website ID</item>
      <item name="visible" xsi:type="boolean">true</item>
      <item name="dataType" xsi:type="string">text</item>
      <item name="formElement" xsi:type="string">input</item>
      <item name="source" xsi:type="string">customer_groups_price_container</item>
      <item name="dataScope" xsi:type="string">website_id</item>
      <item name="required" xsi:type="boolean">true</item>
      </item>
      </argument>
      </field>

      <field name="customer_group_id">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="label" xsi:type="string">Customer Group</item>
      <item name="visible" xsi:type="boolean">true</item>
      <item name="dataType" xsi:type="string">text</item>
      <item name="formElement" xsi:type="string">select</item>
      <item name="source" xsi:type="string">customer_groups_price_container</item>
      <item name="dataScope" xsi:type="string">customer_group_id</item>
      <item name="required" xsi:type="boolean">true</item>
      </item>
      <item name="options" xsi:type="object">MagentoCatalogRuleModelRuleCustomerGroupsOptionsProvider</item>
      </argument>
      </field>

      <field name="price">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="label" xsi:type="string">Special Price</item>
      <item name="visible" xsi:type="boolean">true</item>
      <item name="dataType" xsi:type="string">text</item>
      <item name="formElement" xsi:type="string">input</item>
      <item name="source" xsi:type="string">customer_groups_price_container</item>
      <item name="dataScope" xsi:type="string">price</item>
      <item name="required" xsi:type="boolean">true</item>
      </item>
      </argument>
      </field>
      </container>
      </container>
      </fieldset>




      The custom form fieldset renders as expected:
      enter image description here



      but the rest of the product data is not loaded. I can see from inspecting using DevTools in Chrome that the data model for the product is loaded and all product data is there:
      enter image description here
      it just isn't populating in the form fields when I add my custom datasource. Can anyone help me add the custom datasource without losing the rest of the product data please?







      magento2 admin uicomponent adminform data-provider






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 2 at 12:43









      DavidDavid

      186




      186




















          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
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f256458%2fadd-custom-product-form-custom-data-source-without-overriding-product-data-sourc%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















          draft saved

          draft discarded
















































          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%2f256458%2fadd-custom-product-form-custom-data-source-without-overriding-product-data-sourc%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

          Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

          Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

          Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form