Magento 2: Creating dynamic matrix in new/edit product pageHow to add custom Js code in a “dynamic-rows” component?Magento 2 - How to add dynamic-rows grid on catalog productAdd custom dynamic column in sales order grid Magento 2Magento 2.2.0 : TypeError: element.getRecordCount is not a function in dynamic rows in admin formMagento 2 - UI Fileuploader not passing data in product edit formError is showing saved data from database and display in dynamic row grid Magento 2How to create dynamic rows field in custom Ui component formAdd new button in product page in M2Dynamic Rows can not delete in edit form in admin magento 2Add a new section in product edit page

What is the point of Germany's 299 "party seats" in the Bundestag?

Pulling the rope with one hand is as heavy as with two hands?

With a Canadian student visa, can I spend a night at Vancouver before continuing to Toronto?

Why do Computer Science majors learn Calculus?

Does this extra sentence in the description of the warlock's Eyes of the Rune Keeper eldritch invocation appear in any official reference?

How do we know that ממחרת השבת means from the first day of pesach and not the seventh?

How to back up a running remote server?

Is it possible to measure lightning discharges as Nikola Tesla?

What does KSP mean?

Don’t seats that recline flat defeat the purpose of having seatbelts?

How can I practically buy stocks?

Any examples of headwear for races with animal ears?

Is DC-to-DC (24 V to 12 V) buck conversion typically more efficient than AC-to-DC (110 V to 12 V) conversion?

Why the difference in metal between 銀行 and お金?

What does YCWCYODFTRFDTY mean?

Help to reproduce a tcolorbox with a decoration

Mac Pro install disk keeps ejecting itself

Can solid acids and bases have pH values? If not, how are they classified as acids or bases?

Single Colour Mastermind Problem

Why do 401k up to company match, then fill Roth IRA, then finish filling 401k?

How to pronounce 'C++' in Spanish

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

Do I have to worry about players making “bad” choices on level up?

Will a top journal at least read my introduction?



Magento 2: Creating dynamic matrix in new/edit product page


How to add custom Js code in a “dynamic-rows” component?Magento 2 - How to add dynamic-rows grid on catalog productAdd custom dynamic column in sales order grid Magento 2Magento 2.2.0 : TypeError: element.getRecordCount is not a function in dynamic rows in admin formMagento 2 - UI Fileuploader not passing data in product edit formError is showing saved data from database and display in dynamic row grid Magento 2How to create dynamic rows field in custom Ui component formAdd new button in product page in M2Dynamic Rows can not delete in edit form in admin magento 2Add a new section in product edit page






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








1















I need to create a custom matrix for every product on Magento 2 product add/edit page. I need to have both the rows and columns to be dynamic so when someone click add button for either row or column there should be a row or column created depending upon his choice.



I tried to find solution for my problem but I don't think Magento 2 supports anything like this however we can only add dynamic rows in Magento 2 but not Dynamic columns either.



So I decided to create a custom block on product page to use third-party extension for achieving my goal and then serializing the matrix data when the save button on product page is clicked and append it to form data somehow and get in my observer/plugin and process it according to my need.



Problems:



  • I tried to add a custom block in Magento 2 product page by this article but I couldn't see that it's rendered on the page (may be some xml related stuff is updated in M2.2).


  • Is there really a way we can do so with Magento2? If no then please suggest me how can I add custom block on product page and how to link the matrix data with product form so when I submit it it can be captured on back-end.










share|improve this question
























  • Hi Umar, Have you figured how to add dynamic rows ? please share if you have done.

    – Ajwad Taqvi
    4 hours ago

















1















I need to create a custom matrix for every product on Magento 2 product add/edit page. I need to have both the rows and columns to be dynamic so when someone click add button for either row or column there should be a row or column created depending upon his choice.



I tried to find solution for my problem but I don't think Magento 2 supports anything like this however we can only add dynamic rows in Magento 2 but not Dynamic columns either.



So I decided to create a custom block on product page to use third-party extension for achieving my goal and then serializing the matrix data when the save button on product page is clicked and append it to form data somehow and get in my observer/plugin and process it according to my need.



Problems:



  • I tried to add a custom block in Magento 2 product page by this article but I couldn't see that it's rendered on the page (may be some xml related stuff is updated in M2.2).


  • Is there really a way we can do so with Magento2? If no then please suggest me how can I add custom block on product page and how to link the matrix data with product form so when I submit it it can be captured on back-end.










share|improve this question
























  • Hi Umar, Have you figured how to add dynamic rows ? please share if you have done.

    – Ajwad Taqvi
    4 hours ago













1












1








1








I need to create a custom matrix for every product on Magento 2 product add/edit page. I need to have both the rows and columns to be dynamic so when someone click add button for either row or column there should be a row or column created depending upon his choice.



I tried to find solution for my problem but I don't think Magento 2 supports anything like this however we can only add dynamic rows in Magento 2 but not Dynamic columns either.



So I decided to create a custom block on product page to use third-party extension for achieving my goal and then serializing the matrix data when the save button on product page is clicked and append it to form data somehow and get in my observer/plugin and process it according to my need.



Problems:



  • I tried to add a custom block in Magento 2 product page by this article but I couldn't see that it's rendered on the page (may be some xml related stuff is updated in M2.2).


  • Is there really a way we can do so with Magento2? If no then please suggest me how can I add custom block on product page and how to link the matrix data with product form so when I submit it it can be captured on back-end.










share|improve this question
















I need to create a custom matrix for every product on Magento 2 product add/edit page. I need to have both the rows and columns to be dynamic so when someone click add button for either row or column there should be a row or column created depending upon his choice.



I tried to find solution for my problem but I don't think Magento 2 supports anything like this however we can only add dynamic rows in Magento 2 but not Dynamic columns either.



So I decided to create a custom block on product page to use third-party extension for achieving my goal and then serializing the matrix data when the save button on product page is clicked and append it to form data somehow and get in my observer/plugin and process it according to my need.



Problems:



  • I tried to add a custom block in Magento 2 product page by this article but I couldn't see that it's rendered on the page (may be some xml related stuff is updated in M2.2).


  • Is there really a way we can do so with Magento2? If no then please suggest me how can I add custom block on product page and how to link the matrix data with product form so when I submit it it can be captured on back-end.







magento2 product magento2.2 uicomponent






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 20 '18 at 11:10









Rv Singh

738418




738418










asked Sep 20 '18 at 11:08









UmarUmar

12314




12314












  • Hi Umar, Have you figured how to add dynamic rows ? please share if you have done.

    – Ajwad Taqvi
    4 hours ago

















  • Hi Umar, Have you figured how to add dynamic rows ? please share if you have done.

    – Ajwad Taqvi
    4 hours ago
















Hi Umar, Have you figured how to add dynamic rows ? please share if you have done.

– Ajwad Taqvi
4 hours ago





Hi Umar, Have you figured how to add dynamic rows ? please share if you have done.

– Ajwad Taqvi
4 hours ago










1 Answer
1






active

oldest

votes


















0














Yes this is possible. Here is how we can add dynamic rows to Product Edit Page:



Add DataProvider class as:



etcadminhtmldi.xml



<?xml version="1.0" encoding="UTF-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<virtualType name="MagentoCatalogUiDataProviderProductFormModifierPool">
<arguments>
<argument name="modifiers" xsi:type="array">
<item name="customTab" xsi:type="array">
<item name="class" xsi:type="string">VendorModuleUiDataProviderProductFormModifierNewField</item>
<item name="sortOrder" xsi:type="number">10</item>
</item>
</argument>
</arguments>




And add DataProvider at:



VendorModuleUiDataProviderProductFormModifier:



namespace VendorModuleUiDataProviderProductFormModifier;
use MagentoCatalogModelLocatorLocatorInterface;
use MagentoCatalogUiDataProviderProductFormModifierAbstractModifier;
use MagentoUiComponentFormFieldset;
use MagentoUiComponentFormField;
use MagentoUiComponentFormElementInput;
use MagentoUiComponentDynamicRows;
use MagentoUiComponentContainer;
use MagentoUiComponentFormElementActionDelete;
use MagentoUiComponentFormElementSelect;
use MagentoUiComponentFormElementDataTypeText;
class NewField extends AbstractModifier

const FIELD_IS_DELETE = 'is_delete';
const FIELD_SORT_ORDER_NAME = 'sort_order';
const FIELD_NAME_SELECT = 'select_field';

private $locator;
public function __construct(
LocatorInterface $locator
)
$this->locator = $locator;

public function modifyData(array $data)

return $data;

public function modifyMeta(array $meta)

$meta = array_replace_recursive(
$meta,
[
'custom_fieldset' => [
'arguments' => [
'data' => [
'config' => [
'label' => __('Custom Group'),
'componentType' => Fieldset::NAME,
'dataScope' => 'data.product.custom_fieldset',
'collapsible' => true,
'sortOrder' => 5,
],
],
],
'children' => [
"custom_field" => $this->getSelectTypeGridConfig(10)
],
]
]
);
return $meta;

protected function getSelectTypeGridConfig($sortOrder)
return [
'arguments' => [
'data' => [
'config' => [
'addButtonLabel' => __('Add Value'),
'componentType' => DynamicRows::NAME,
'component' => 'Magento_Ui/js/dynamic-rows/dynamic-rows',
'additionalClasses' => 'admin__field-wide',
'deleteProperty' => static::FIELD_IS_DELETE,
'deleteValue' => '1',
'renderDefaultRecord' => false,
'sortOrder' => $sortOrder,
],
],
],
'children' => [
'record' => [
'arguments' => [
'data' => [
'config' => [
'componentType' => Container::NAME,
'component' => 'Magento_Ui/js/dynamic-rows/record',
'positionProvider' => static::FIELD_SORT_ORDER_NAME,
'isTemplate' => true,
'is_collection' => true,
],
],
],
'children' => [
static::FIELD_NAME_SELECT => $this->getSelectFieldConfig(1),
static::FIELD_IS_DELETE => $this->getIsDeleteFieldConfig(3)
//Add as many fields as you want

]
]
]
];

protected function getSelectFieldConfig($sortOrder)

return [
'arguments' => [
'data' => [
'config' => [
'label' => __('Options Select'),
'componentType' => Field::NAME,
'formElement' => Select::NAME,
'component' => 'Magento_Catalog/js/custom-options-type',
'elementTmpl' => 'ui/grid/filters/elements/ui-select',
// 'selectType' => 'optgroup',
'dataScope' => static::FIELD_NAME_SELECT,
'dataType' => Text::NAME,
'sortOrder' => $sortOrder,
'options' => $this->_getOptions(),
'visible' => true,
'disabled' => false,
],
],
],
];

protected function _getOptions()

$options = [
1 => [
'label' => __('Option 1'),
'value' => 1
],
2 => [
'label' => __('Option 2'),
'value' => 2
],
3 => [
'label' => __('Option 3'),
'value' => 3
],
];

return $options;

protected function getIsDeleteFieldConfig($sortOrder)

return [
'arguments' => [
'data' => [
'config' => [
'componentType' => ActionDelete::NAME,
'fit' => true,
'sortOrder' => $sortOrder
],
],
],
];







share|improve this answer























    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%2f243049%2fmagento-2-creating-dynamic-matrix-in-new-edit-product-page%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Yes this is possible. Here is how we can add dynamic rows to Product Edit Page:



    Add DataProvider class as:



    etcadminhtmldi.xml



    <?xml version="1.0" encoding="UTF-8"?>
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <virtualType name="MagentoCatalogUiDataProviderProductFormModifierPool">
    <arguments>
    <argument name="modifiers" xsi:type="array">
    <item name="customTab" xsi:type="array">
    <item name="class" xsi:type="string">VendorModuleUiDataProviderProductFormModifierNewField</item>
    <item name="sortOrder" xsi:type="number">10</item>
    </item>
    </argument>
    </arguments>




    And add DataProvider at:



    VendorModuleUiDataProviderProductFormModifier:



    namespace VendorModuleUiDataProviderProductFormModifier;
    use MagentoCatalogModelLocatorLocatorInterface;
    use MagentoCatalogUiDataProviderProductFormModifierAbstractModifier;
    use MagentoUiComponentFormFieldset;
    use MagentoUiComponentFormField;
    use MagentoUiComponentFormElementInput;
    use MagentoUiComponentDynamicRows;
    use MagentoUiComponentContainer;
    use MagentoUiComponentFormElementActionDelete;
    use MagentoUiComponentFormElementSelect;
    use MagentoUiComponentFormElementDataTypeText;
    class NewField extends AbstractModifier

    const FIELD_IS_DELETE = 'is_delete';
    const FIELD_SORT_ORDER_NAME = 'sort_order';
    const FIELD_NAME_SELECT = 'select_field';

    private $locator;
    public function __construct(
    LocatorInterface $locator
    )
    $this->locator = $locator;

    public function modifyData(array $data)

    return $data;

    public function modifyMeta(array $meta)

    $meta = array_replace_recursive(
    $meta,
    [
    'custom_fieldset' => [
    'arguments' => [
    'data' => [
    'config' => [
    'label' => __('Custom Group'),
    'componentType' => Fieldset::NAME,
    'dataScope' => 'data.product.custom_fieldset',
    'collapsible' => true,
    'sortOrder' => 5,
    ],
    ],
    ],
    'children' => [
    "custom_field" => $this->getSelectTypeGridConfig(10)
    ],
    ]
    ]
    );
    return $meta;

    protected function getSelectTypeGridConfig($sortOrder)
    return [
    'arguments' => [
    'data' => [
    'config' => [
    'addButtonLabel' => __('Add Value'),
    'componentType' => DynamicRows::NAME,
    'component' => 'Magento_Ui/js/dynamic-rows/dynamic-rows',
    'additionalClasses' => 'admin__field-wide',
    'deleteProperty' => static::FIELD_IS_DELETE,
    'deleteValue' => '1',
    'renderDefaultRecord' => false,
    'sortOrder' => $sortOrder,
    ],
    ],
    ],
    'children' => [
    'record' => [
    'arguments' => [
    'data' => [
    'config' => [
    'componentType' => Container::NAME,
    'component' => 'Magento_Ui/js/dynamic-rows/record',
    'positionProvider' => static::FIELD_SORT_ORDER_NAME,
    'isTemplate' => true,
    'is_collection' => true,
    ],
    ],
    ],
    'children' => [
    static::FIELD_NAME_SELECT => $this->getSelectFieldConfig(1),
    static::FIELD_IS_DELETE => $this->getIsDeleteFieldConfig(3)
    //Add as many fields as you want

    ]
    ]
    ]
    ];

    protected function getSelectFieldConfig($sortOrder)

    return [
    'arguments' => [
    'data' => [
    'config' => [
    'label' => __('Options Select'),
    'componentType' => Field::NAME,
    'formElement' => Select::NAME,
    'component' => 'Magento_Catalog/js/custom-options-type',
    'elementTmpl' => 'ui/grid/filters/elements/ui-select',
    // 'selectType' => 'optgroup',
    'dataScope' => static::FIELD_NAME_SELECT,
    'dataType' => Text::NAME,
    'sortOrder' => $sortOrder,
    'options' => $this->_getOptions(),
    'visible' => true,
    'disabled' => false,
    ],
    ],
    ],
    ];

    protected function _getOptions()

    $options = [
    1 => [
    'label' => __('Option 1'),
    'value' => 1
    ],
    2 => [
    'label' => __('Option 2'),
    'value' => 2
    ],
    3 => [
    'label' => __('Option 3'),
    'value' => 3
    ],
    ];

    return $options;

    protected function getIsDeleteFieldConfig($sortOrder)

    return [
    'arguments' => [
    'data' => [
    'config' => [
    'componentType' => ActionDelete::NAME,
    'fit' => true,
    'sortOrder' => $sortOrder
    ],
    ],
    ],
    ];







    share|improve this answer



























      0














      Yes this is possible. Here is how we can add dynamic rows to Product Edit Page:



      Add DataProvider class as:



      etcadminhtmldi.xml



      <?xml version="1.0" encoding="UTF-8"?>
      <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
      <virtualType name="MagentoCatalogUiDataProviderProductFormModifierPool">
      <arguments>
      <argument name="modifiers" xsi:type="array">
      <item name="customTab" xsi:type="array">
      <item name="class" xsi:type="string">VendorModuleUiDataProviderProductFormModifierNewField</item>
      <item name="sortOrder" xsi:type="number">10</item>
      </item>
      </argument>
      </arguments>




      And add DataProvider at:



      VendorModuleUiDataProviderProductFormModifier:



      namespace VendorModuleUiDataProviderProductFormModifier;
      use MagentoCatalogModelLocatorLocatorInterface;
      use MagentoCatalogUiDataProviderProductFormModifierAbstractModifier;
      use MagentoUiComponentFormFieldset;
      use MagentoUiComponentFormField;
      use MagentoUiComponentFormElementInput;
      use MagentoUiComponentDynamicRows;
      use MagentoUiComponentContainer;
      use MagentoUiComponentFormElementActionDelete;
      use MagentoUiComponentFormElementSelect;
      use MagentoUiComponentFormElementDataTypeText;
      class NewField extends AbstractModifier

      const FIELD_IS_DELETE = 'is_delete';
      const FIELD_SORT_ORDER_NAME = 'sort_order';
      const FIELD_NAME_SELECT = 'select_field';

      private $locator;
      public function __construct(
      LocatorInterface $locator
      )
      $this->locator = $locator;

      public function modifyData(array $data)

      return $data;

      public function modifyMeta(array $meta)

      $meta = array_replace_recursive(
      $meta,
      [
      'custom_fieldset' => [
      'arguments' => [
      'data' => [
      'config' => [
      'label' => __('Custom Group'),
      'componentType' => Fieldset::NAME,
      'dataScope' => 'data.product.custom_fieldset',
      'collapsible' => true,
      'sortOrder' => 5,
      ],
      ],
      ],
      'children' => [
      "custom_field" => $this->getSelectTypeGridConfig(10)
      ],
      ]
      ]
      );
      return $meta;

      protected function getSelectTypeGridConfig($sortOrder)
      return [
      'arguments' => [
      'data' => [
      'config' => [
      'addButtonLabel' => __('Add Value'),
      'componentType' => DynamicRows::NAME,
      'component' => 'Magento_Ui/js/dynamic-rows/dynamic-rows',
      'additionalClasses' => 'admin__field-wide',
      'deleteProperty' => static::FIELD_IS_DELETE,
      'deleteValue' => '1',
      'renderDefaultRecord' => false,
      'sortOrder' => $sortOrder,
      ],
      ],
      ],
      'children' => [
      'record' => [
      'arguments' => [
      'data' => [
      'config' => [
      'componentType' => Container::NAME,
      'component' => 'Magento_Ui/js/dynamic-rows/record',
      'positionProvider' => static::FIELD_SORT_ORDER_NAME,
      'isTemplate' => true,
      'is_collection' => true,
      ],
      ],
      ],
      'children' => [
      static::FIELD_NAME_SELECT => $this->getSelectFieldConfig(1),
      static::FIELD_IS_DELETE => $this->getIsDeleteFieldConfig(3)
      //Add as many fields as you want

      ]
      ]
      ]
      ];

      protected function getSelectFieldConfig($sortOrder)

      return [
      'arguments' => [
      'data' => [
      'config' => [
      'label' => __('Options Select'),
      'componentType' => Field::NAME,
      'formElement' => Select::NAME,
      'component' => 'Magento_Catalog/js/custom-options-type',
      'elementTmpl' => 'ui/grid/filters/elements/ui-select',
      // 'selectType' => 'optgroup',
      'dataScope' => static::FIELD_NAME_SELECT,
      'dataType' => Text::NAME,
      'sortOrder' => $sortOrder,
      'options' => $this->_getOptions(),
      'visible' => true,
      'disabled' => false,
      ],
      ],
      ],
      ];

      protected function _getOptions()

      $options = [
      1 => [
      'label' => __('Option 1'),
      'value' => 1
      ],
      2 => [
      'label' => __('Option 2'),
      'value' => 2
      ],
      3 => [
      'label' => __('Option 3'),
      'value' => 3
      ],
      ];

      return $options;

      protected function getIsDeleteFieldConfig($sortOrder)

      return [
      'arguments' => [
      'data' => [
      'config' => [
      'componentType' => ActionDelete::NAME,
      'fit' => true,
      'sortOrder' => $sortOrder
      ],
      ],
      ],
      ];







      share|improve this answer

























        0












        0








        0







        Yes this is possible. Here is how we can add dynamic rows to Product Edit Page:



        Add DataProvider class as:



        etcadminhtmldi.xml



        <?xml version="1.0" encoding="UTF-8"?>
        <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
        <virtualType name="MagentoCatalogUiDataProviderProductFormModifierPool">
        <arguments>
        <argument name="modifiers" xsi:type="array">
        <item name="customTab" xsi:type="array">
        <item name="class" xsi:type="string">VendorModuleUiDataProviderProductFormModifierNewField</item>
        <item name="sortOrder" xsi:type="number">10</item>
        </item>
        </argument>
        </arguments>




        And add DataProvider at:



        VendorModuleUiDataProviderProductFormModifier:



        namespace VendorModuleUiDataProviderProductFormModifier;
        use MagentoCatalogModelLocatorLocatorInterface;
        use MagentoCatalogUiDataProviderProductFormModifierAbstractModifier;
        use MagentoUiComponentFormFieldset;
        use MagentoUiComponentFormField;
        use MagentoUiComponentFormElementInput;
        use MagentoUiComponentDynamicRows;
        use MagentoUiComponentContainer;
        use MagentoUiComponentFormElementActionDelete;
        use MagentoUiComponentFormElementSelect;
        use MagentoUiComponentFormElementDataTypeText;
        class NewField extends AbstractModifier

        const FIELD_IS_DELETE = 'is_delete';
        const FIELD_SORT_ORDER_NAME = 'sort_order';
        const FIELD_NAME_SELECT = 'select_field';

        private $locator;
        public function __construct(
        LocatorInterface $locator
        )
        $this->locator = $locator;

        public function modifyData(array $data)

        return $data;

        public function modifyMeta(array $meta)

        $meta = array_replace_recursive(
        $meta,
        [
        'custom_fieldset' => [
        'arguments' => [
        'data' => [
        'config' => [
        'label' => __('Custom Group'),
        'componentType' => Fieldset::NAME,
        'dataScope' => 'data.product.custom_fieldset',
        'collapsible' => true,
        'sortOrder' => 5,
        ],
        ],
        ],
        'children' => [
        "custom_field" => $this->getSelectTypeGridConfig(10)
        ],
        ]
        ]
        );
        return $meta;

        protected function getSelectTypeGridConfig($sortOrder)
        return [
        'arguments' => [
        'data' => [
        'config' => [
        'addButtonLabel' => __('Add Value'),
        'componentType' => DynamicRows::NAME,
        'component' => 'Magento_Ui/js/dynamic-rows/dynamic-rows',
        'additionalClasses' => 'admin__field-wide',
        'deleteProperty' => static::FIELD_IS_DELETE,
        'deleteValue' => '1',
        'renderDefaultRecord' => false,
        'sortOrder' => $sortOrder,
        ],
        ],
        ],
        'children' => [
        'record' => [
        'arguments' => [
        'data' => [
        'config' => [
        'componentType' => Container::NAME,
        'component' => 'Magento_Ui/js/dynamic-rows/record',
        'positionProvider' => static::FIELD_SORT_ORDER_NAME,
        'isTemplate' => true,
        'is_collection' => true,
        ],
        ],
        ],
        'children' => [
        static::FIELD_NAME_SELECT => $this->getSelectFieldConfig(1),
        static::FIELD_IS_DELETE => $this->getIsDeleteFieldConfig(3)
        //Add as many fields as you want

        ]
        ]
        ]
        ];

        protected function getSelectFieldConfig($sortOrder)

        return [
        'arguments' => [
        'data' => [
        'config' => [
        'label' => __('Options Select'),
        'componentType' => Field::NAME,
        'formElement' => Select::NAME,
        'component' => 'Magento_Catalog/js/custom-options-type',
        'elementTmpl' => 'ui/grid/filters/elements/ui-select',
        // 'selectType' => 'optgroup',
        'dataScope' => static::FIELD_NAME_SELECT,
        'dataType' => Text::NAME,
        'sortOrder' => $sortOrder,
        'options' => $this->_getOptions(),
        'visible' => true,
        'disabled' => false,
        ],
        ],
        ],
        ];

        protected function _getOptions()

        $options = [
        1 => [
        'label' => __('Option 1'),
        'value' => 1
        ],
        2 => [
        'label' => __('Option 2'),
        'value' => 2
        ],
        3 => [
        'label' => __('Option 3'),
        'value' => 3
        ],
        ];

        return $options;

        protected function getIsDeleteFieldConfig($sortOrder)

        return [
        'arguments' => [
        'data' => [
        'config' => [
        'componentType' => ActionDelete::NAME,
        'fit' => true,
        'sortOrder' => $sortOrder
        ],
        ],
        ],
        ];







        share|improve this answer













        Yes this is possible. Here is how we can add dynamic rows to Product Edit Page:



        Add DataProvider class as:



        etcadminhtmldi.xml



        <?xml version="1.0" encoding="UTF-8"?>
        <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
        <virtualType name="MagentoCatalogUiDataProviderProductFormModifierPool">
        <arguments>
        <argument name="modifiers" xsi:type="array">
        <item name="customTab" xsi:type="array">
        <item name="class" xsi:type="string">VendorModuleUiDataProviderProductFormModifierNewField</item>
        <item name="sortOrder" xsi:type="number">10</item>
        </item>
        </argument>
        </arguments>




        And add DataProvider at:



        VendorModuleUiDataProviderProductFormModifier:



        namespace VendorModuleUiDataProviderProductFormModifier;
        use MagentoCatalogModelLocatorLocatorInterface;
        use MagentoCatalogUiDataProviderProductFormModifierAbstractModifier;
        use MagentoUiComponentFormFieldset;
        use MagentoUiComponentFormField;
        use MagentoUiComponentFormElementInput;
        use MagentoUiComponentDynamicRows;
        use MagentoUiComponentContainer;
        use MagentoUiComponentFormElementActionDelete;
        use MagentoUiComponentFormElementSelect;
        use MagentoUiComponentFormElementDataTypeText;
        class NewField extends AbstractModifier

        const FIELD_IS_DELETE = 'is_delete';
        const FIELD_SORT_ORDER_NAME = 'sort_order';
        const FIELD_NAME_SELECT = 'select_field';

        private $locator;
        public function __construct(
        LocatorInterface $locator
        )
        $this->locator = $locator;

        public function modifyData(array $data)

        return $data;

        public function modifyMeta(array $meta)

        $meta = array_replace_recursive(
        $meta,
        [
        'custom_fieldset' => [
        'arguments' => [
        'data' => [
        'config' => [
        'label' => __('Custom Group'),
        'componentType' => Fieldset::NAME,
        'dataScope' => 'data.product.custom_fieldset',
        'collapsible' => true,
        'sortOrder' => 5,
        ],
        ],
        ],
        'children' => [
        "custom_field" => $this->getSelectTypeGridConfig(10)
        ],
        ]
        ]
        );
        return $meta;

        protected function getSelectTypeGridConfig($sortOrder)
        return [
        'arguments' => [
        'data' => [
        'config' => [
        'addButtonLabel' => __('Add Value'),
        'componentType' => DynamicRows::NAME,
        'component' => 'Magento_Ui/js/dynamic-rows/dynamic-rows',
        'additionalClasses' => 'admin__field-wide',
        'deleteProperty' => static::FIELD_IS_DELETE,
        'deleteValue' => '1',
        'renderDefaultRecord' => false,
        'sortOrder' => $sortOrder,
        ],
        ],
        ],
        'children' => [
        'record' => [
        'arguments' => [
        'data' => [
        'config' => [
        'componentType' => Container::NAME,
        'component' => 'Magento_Ui/js/dynamic-rows/record',
        'positionProvider' => static::FIELD_SORT_ORDER_NAME,
        'isTemplate' => true,
        'is_collection' => true,
        ],
        ],
        ],
        'children' => [
        static::FIELD_NAME_SELECT => $this->getSelectFieldConfig(1),
        static::FIELD_IS_DELETE => $this->getIsDeleteFieldConfig(3)
        //Add as many fields as you want

        ]
        ]
        ]
        ];

        protected function getSelectFieldConfig($sortOrder)

        return [
        'arguments' => [
        'data' => [
        'config' => [
        'label' => __('Options Select'),
        'componentType' => Field::NAME,
        'formElement' => Select::NAME,
        'component' => 'Magento_Catalog/js/custom-options-type',
        'elementTmpl' => 'ui/grid/filters/elements/ui-select',
        // 'selectType' => 'optgroup',
        'dataScope' => static::FIELD_NAME_SELECT,
        'dataType' => Text::NAME,
        'sortOrder' => $sortOrder,
        'options' => $this->_getOptions(),
        'visible' => true,
        'disabled' => false,
        ],
        ],
        ],
        ];

        protected function _getOptions()

        $options = [
        1 => [
        'label' => __('Option 1'),
        'value' => 1
        ],
        2 => [
        'label' => __('Option 2'),
        'value' => 2
        ],
        3 => [
        'label' => __('Option 3'),
        'value' => 3
        ],
        ];

        return $options;

        protected function getIsDeleteFieldConfig($sortOrder)

        return [
        'arguments' => [
        'data' => [
        'config' => [
        'componentType' => ActionDelete::NAME,
        'fit' => true,
        'sortOrder' => $sortOrder
        ],
        ],
        ],
        ];








        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 11 mins ago









        Ajwad TaqviAjwad Taqvi

        417116




        417116



























            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%2f243049%2fmagento-2-creating-dynamic-matrix-in-new-edit-product-page%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

            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

            Nissan Patrol Зміст Перше покоління — 4W60 (1951-1960) | Друге покоління — 60 series (1960-1980) | Третє покоління (1980–2002) | Четверте покоління — Y60 (1987–1998) | П'яте покоління — Y61 (1997–2013) | Шосте покоління — Y62 (2010- ) | Посилання | Зноски | Навігаційне менюОфіційний український сайтТест-драйв Nissan Patrol 2010 7-го поколінняNissan PatrolКак мы тестировали Nissan Patrol 2016рвиправивши або дописавши її