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;
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
add a comment |
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
Hi Umar, Have you figured how to add dynamic rows ? please share if you have done.
– Ajwad Taqvi
4 hours ago
add a comment |
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
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
magento2 product magento2.2 uicomponent
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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
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
],
],
],
];
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
],
],
],
];
add a comment |
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
],
],
],
];
add a comment |
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
],
],
],
];
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
],
],
],
];
answered 11 mins ago
Ajwad TaqviAjwad Taqvi
417116
417116
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
Hi Umar, Have you figured how to add dynamic rows ? please share if you have done.
– Ajwad Taqvi
4 hours ago