Magento 2 - Dynamic rows based on related products modal grid on custom form with tabsHow can i rewrite...
How could our ancestors have domesticated a solitary predator?
Is "history" a male-biased word ("his+story")?
Ban on all campaign finance?
Extension of Splitting Fields over An Arbitrary Field
How do anti-virus programs start at Windows boot?
Is having access to past exams cheating and, if yes, could it be proven just by a good grade?
"However" used in a conditional clause?
Silly Sally's Movie
Making a sword in the stone, in a medieval world without magic
Excess Zinc in garden soil
Can "semicircle" be used to refer to a part-circle that is not a exact half-circle?
Who is our nearest neighbor
Co-worker team leader wants to inject the crap software product of his friends into our development. What should I say to our common boss?
When two POV characters meet
Draw arrow on sides of triangle
When were linguistics departments first established
Coworker uses her breast-pump everywhere in the office
Is it ok to include an epilogue dedicated to colleagues who passed away in the end of the manuscript?
Want to switch to tankless, but can I use my existing wiring?
Does splitting a potentially monolithic application into several smaller ones help prevent bugs?
Unreachable code, but reachable with exception
Good allowance savings plan?
Is it illegal in Germany to take sick leave if you caused your own illness with food?
If the Captain's screens are out, does he switch seats with the co-pilot?
Magento 2 - Dynamic rows based on related products modal grid on custom form with tabs
How can i rewrite TierPrice Block in Magento2Magento 2:Custom Field Value in Edit Products SectionMagento 2 - insertListing ui componentAdd custom dynamic column in sales order grid Magento 2An Error while add a complex component modal as insertlisting for add dynamic row in my ui-component admin formMagento 2 declaring modifier PHP Fatal Error: null given in $modifiersMissing required argument $modifiers of MagentoUiDataProviderModifierPoolError is showing saved data from database and display in dynamic row grid Magento 2How to create dynamic rows field in custom Ui component form
I am working on magento 2.1 backend module. Basically backend part is a form that contain tabs. I ahve here some standard inputs but also some dynamic rows etc. Everything is working fine except the last tab. Last tab is a MODAL that allow us to choose products that will not be available for the entity that we are editing/creating.
Basically idea of working is exactly same as on product edit form for related products, so: we have a button "Add related products", modal render with grid of products then we can select them and after click "Add selected products" we have them rendered in dynamic grid rows.
I was able to reproduce some part of this logic on my custom form:
- custom tab with button "Add unavailable products"
- after click modal render
- inside modal I have a product list
- when selecting product and clicking "Add selected products" modal disappear
- when opening modal again the list is filtered (does not contain previously selected elements)
- DYNAMIC GRID is not populated :(
I do not know where is the problem with dynamic grid :/ there are no errors in the console, no error logs, etc. Does anyone worked with those components or maybe have a idea what to do to make it works?
I saw some referrences into this doc:
http://devdocs.magento.com/guides/v2.1/ui-components/ui_dynamic_rows.html
but it is not working :/
This is how the tab looks like:
Some implementation details:
Main form is declared on adminhtml/ui_component/my_component_form.xml and looks like this:
<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">my_component_form.my_component_form_data_source</item>
<item name="deps" xsi:type="string">my_component_form.my_component_form_data_source</item>
<item name="namespace" xsi:type="string">my_component_form</item>
</item>
<item name="label" xsi:type="string" translate="true">Agency Information</item>
<item name="layout" xsi:type="array">
<item name="type" xsi:type="string">tabs</item>
<item name="navContainerName" xsi:type="string">left</item>
</item>
<item name="buttons" xsi:type="array">
<item name="back" xsi:type="string">MyModuleAgencyBlockAdminhtmlAgencyEditBackButton</item>
<item name="delete" xsi:type="string">MyModuleAgencyBlockAdminhtmlAgencyEditDeleteButton</item>
<item name="reset" xsi:type="string">MyModuleAgencyBlockAdminhtmlAgencyEditResetButton</item>
<item name="save" xsi:type="string">MyModuleAgencyBlockAdminhtmlAgencyEditSaveButton</item>
<item name="save_and_continue" xsi:type="string">MyModuleAgencyBlockAdminhtmlAgencyEditSaveAndContinueButton</item>
</item>
<item name="reverseMetadataMerge" xsi:type="boolean">true</item>
</argument>
<dataSource name="my_component_form_data_source">
<argument name="dataProvider" xsi:type="configurableObject">
<argument name="class" xsi:type="string">MyModuleAgencyUiComponentEditForm</argument>
<argument name="name" xsi:type="string">my_component_form_data_source</argument>
<argument name="primaryFieldName" xsi:type="string">agency_id</argument>
<argument name="requestFieldName" xsi:type="string">agency_id</argument>
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="submit_url" xsi:type="url" path="my_component/agency/save"/>
</item>
</argument>
</argument>
<argument name="data" xsi:type="array">
<item name="js_config" xsi:type="array">
<item name="component" xsi:type="string">Magento_Ui/js/form/provider</item>
</item>
</argument>
</dataSource>
Last tab is added with Modifier class (like Related product), and my adminhtml/di.xml file looks like:
<virtualType name="MyModuleAgencyUiComponentEditModifierPool" type="MagentoUiDataProviderModifierPool">
<arguments>
<argument name="modifiers" xsi:type="array">
<item name="availability" xsi:type="array">
<item name="class" xsi:type="string">MyModuleAgencyUiComponentEditModifierUnavailableProducts</item>
<item name="sortOrder" xsi:type="number">200</item>
</item>
</argument>
</arguments>
</virtualType>
<type name="MyModuleAgencyUiComponentEditForm">
<arguments>
<argument name="pool" xsi:type="object">MyModuleAgencyUiComponentEditModifierPool</argument>
</arguments>
</type>
<type name="MyModuleAgencyUiComponentEditModifierUnavailableProducts">
<arguments>
<argument name="scopeName" xsi:type="string">my_component_form.areas</argument>
</arguments>
</type>
My getMeta method on DataProvider class (Form) is:
public function getMeta()
{
$meta = parent::getMeta();
/** @var ModifierInterface $modifier */
foreach ($this->pool->getModifiersInstances() as $modifier) {
$meta = $modifier->modifyMeta($meta);
}
return $meta;
}
And last part -> my modifier class extends Related products class, and field construction looks like:
class UnavailableProducts extends Related
{
...
...
...
/**
* {@inheritdoc}
*/
protected function getButtonSet(Phrase $content, Phrase $buttonTitle, $scope)
{
$config = parent::getButtonSet($content, $buttonTitle, $scope);
$modalTarget = $this->scopeName . '.' . 'unavailable' . '.' . $scope . '.modal';
// We need to update some button config in order to make sure that the modal box is linked to the proper button
$config['children']['button_' . $scope]['arguments']['data']['config']['actions'][0]['targetName'] = $modalTarget;
$config['children']['button_' . $scope]['arguments']['data']['config']['actions'][1]['targetName'] = $modalTarget . '.' . $scope . '_product_listing';
return $config;
}
public function modifyMeta(array $meta)
{
$meta = array_replace_recursive(
$meta,
[
// Let's add a new fieldset group
static::EASYCORE_AGENCY => [
'children' => [
'button_set' => $this->getButtonSet(
__('Products that are present here are not available for this agency'),
__('Add Unavailable Products'),
$this->scopePrefix . 'unavailable'
),
'modal' => $this->getGenericModal(
__('Add Unavailable Products'),
$this->scopePrefix . 'unavailable'
),
'unavailable' => $this->getGrid('unavailable')
],
'arguments' => [
'data' => [
'config' => [
'label' => __('Unavailable products'),
'collapsible' => false,
'componentType' => Fieldset::NAME,
'dataScope' => static::DATA_SCOPE,
'sortOrder' => 200
],
],
],
],
]
);
return $meta;
}
If we take a look inside Related class we will see that on grid config there is value like:
'links' => [
'insertData' => '${ $.provider }:${ $.dataProvider }'
],
I suspect that the problem is somewhere on grid or dynamic row configuration... But I am unable to find it on my own :/ Any help would be great.
magento2 grid modal dynamic-rows
add a comment |
I am working on magento 2.1 backend module. Basically backend part is a form that contain tabs. I ahve here some standard inputs but also some dynamic rows etc. Everything is working fine except the last tab. Last tab is a MODAL that allow us to choose products that will not be available for the entity that we are editing/creating.
Basically idea of working is exactly same as on product edit form for related products, so: we have a button "Add related products", modal render with grid of products then we can select them and after click "Add selected products" we have them rendered in dynamic grid rows.
I was able to reproduce some part of this logic on my custom form:
- custom tab with button "Add unavailable products"
- after click modal render
- inside modal I have a product list
- when selecting product and clicking "Add selected products" modal disappear
- when opening modal again the list is filtered (does not contain previously selected elements)
- DYNAMIC GRID is not populated :(
I do not know where is the problem with dynamic grid :/ there are no errors in the console, no error logs, etc. Does anyone worked with those components or maybe have a idea what to do to make it works?
I saw some referrences into this doc:
http://devdocs.magento.com/guides/v2.1/ui-components/ui_dynamic_rows.html
but it is not working :/
This is how the tab looks like:
Some implementation details:
Main form is declared on adminhtml/ui_component/my_component_form.xml and looks like this:
<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">my_component_form.my_component_form_data_source</item>
<item name="deps" xsi:type="string">my_component_form.my_component_form_data_source</item>
<item name="namespace" xsi:type="string">my_component_form</item>
</item>
<item name="label" xsi:type="string" translate="true">Agency Information</item>
<item name="layout" xsi:type="array">
<item name="type" xsi:type="string">tabs</item>
<item name="navContainerName" xsi:type="string">left</item>
</item>
<item name="buttons" xsi:type="array">
<item name="back" xsi:type="string">MyModuleAgencyBlockAdminhtmlAgencyEditBackButton</item>
<item name="delete" xsi:type="string">MyModuleAgencyBlockAdminhtmlAgencyEditDeleteButton</item>
<item name="reset" xsi:type="string">MyModuleAgencyBlockAdminhtmlAgencyEditResetButton</item>
<item name="save" xsi:type="string">MyModuleAgencyBlockAdminhtmlAgencyEditSaveButton</item>
<item name="save_and_continue" xsi:type="string">MyModuleAgencyBlockAdminhtmlAgencyEditSaveAndContinueButton</item>
</item>
<item name="reverseMetadataMerge" xsi:type="boolean">true</item>
</argument>
<dataSource name="my_component_form_data_source">
<argument name="dataProvider" xsi:type="configurableObject">
<argument name="class" xsi:type="string">MyModuleAgencyUiComponentEditForm</argument>
<argument name="name" xsi:type="string">my_component_form_data_source</argument>
<argument name="primaryFieldName" xsi:type="string">agency_id</argument>
<argument name="requestFieldName" xsi:type="string">agency_id</argument>
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="submit_url" xsi:type="url" path="my_component/agency/save"/>
</item>
</argument>
</argument>
<argument name="data" xsi:type="array">
<item name="js_config" xsi:type="array">
<item name="component" xsi:type="string">Magento_Ui/js/form/provider</item>
</item>
</argument>
</dataSource>
Last tab is added with Modifier class (like Related product), and my adminhtml/di.xml file looks like:
<virtualType name="MyModuleAgencyUiComponentEditModifierPool" type="MagentoUiDataProviderModifierPool">
<arguments>
<argument name="modifiers" xsi:type="array">
<item name="availability" xsi:type="array">
<item name="class" xsi:type="string">MyModuleAgencyUiComponentEditModifierUnavailableProducts</item>
<item name="sortOrder" xsi:type="number">200</item>
</item>
</argument>
</arguments>
</virtualType>
<type name="MyModuleAgencyUiComponentEditForm">
<arguments>
<argument name="pool" xsi:type="object">MyModuleAgencyUiComponentEditModifierPool</argument>
</arguments>
</type>
<type name="MyModuleAgencyUiComponentEditModifierUnavailableProducts">
<arguments>
<argument name="scopeName" xsi:type="string">my_component_form.areas</argument>
</arguments>
</type>
My getMeta method on DataProvider class (Form) is:
public function getMeta()
{
$meta = parent::getMeta();
/** @var ModifierInterface $modifier */
foreach ($this->pool->getModifiersInstances() as $modifier) {
$meta = $modifier->modifyMeta($meta);
}
return $meta;
}
And last part -> my modifier class extends Related products class, and field construction looks like:
class UnavailableProducts extends Related
{
...
...
...
/**
* {@inheritdoc}
*/
protected function getButtonSet(Phrase $content, Phrase $buttonTitle, $scope)
{
$config = parent::getButtonSet($content, $buttonTitle, $scope);
$modalTarget = $this->scopeName . '.' . 'unavailable' . '.' . $scope . '.modal';
// We need to update some button config in order to make sure that the modal box is linked to the proper button
$config['children']['button_' . $scope]['arguments']['data']['config']['actions'][0]['targetName'] = $modalTarget;
$config['children']['button_' . $scope]['arguments']['data']['config']['actions'][1]['targetName'] = $modalTarget . '.' . $scope . '_product_listing';
return $config;
}
public function modifyMeta(array $meta)
{
$meta = array_replace_recursive(
$meta,
[
// Let's add a new fieldset group
static::EASYCORE_AGENCY => [
'children' => [
'button_set' => $this->getButtonSet(
__('Products that are present here are not available for this agency'),
__('Add Unavailable Products'),
$this->scopePrefix . 'unavailable'
),
'modal' => $this->getGenericModal(
__('Add Unavailable Products'),
$this->scopePrefix . 'unavailable'
),
'unavailable' => $this->getGrid('unavailable')
],
'arguments' => [
'data' => [
'config' => [
'label' => __('Unavailable products'),
'collapsible' => false,
'componentType' => Fieldset::NAME,
'dataScope' => static::DATA_SCOPE,
'sortOrder' => 200
],
],
],
],
]
);
return $meta;
}
If we take a look inside Related class we will see that on grid config there is value like:
'links' => [
'insertData' => '${ $.provider }:${ $.dataProvider }'
],
I suspect that the problem is somewhere on grid or dynamic row configuration... But I am unable to find it on my own :/ Any help would be great.
magento2 grid modal dynamic-rows
add a comment |
I am working on magento 2.1 backend module. Basically backend part is a form that contain tabs. I ahve here some standard inputs but also some dynamic rows etc. Everything is working fine except the last tab. Last tab is a MODAL that allow us to choose products that will not be available for the entity that we are editing/creating.
Basically idea of working is exactly same as on product edit form for related products, so: we have a button "Add related products", modal render with grid of products then we can select them and after click "Add selected products" we have them rendered in dynamic grid rows.
I was able to reproduce some part of this logic on my custom form:
- custom tab with button "Add unavailable products"
- after click modal render
- inside modal I have a product list
- when selecting product and clicking "Add selected products" modal disappear
- when opening modal again the list is filtered (does not contain previously selected elements)
- DYNAMIC GRID is not populated :(
I do not know where is the problem with dynamic grid :/ there are no errors in the console, no error logs, etc. Does anyone worked with those components or maybe have a idea what to do to make it works?
I saw some referrences into this doc:
http://devdocs.magento.com/guides/v2.1/ui-components/ui_dynamic_rows.html
but it is not working :/
This is how the tab looks like:
Some implementation details:
Main form is declared on adminhtml/ui_component/my_component_form.xml and looks like this:
<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">my_component_form.my_component_form_data_source</item>
<item name="deps" xsi:type="string">my_component_form.my_component_form_data_source</item>
<item name="namespace" xsi:type="string">my_component_form</item>
</item>
<item name="label" xsi:type="string" translate="true">Agency Information</item>
<item name="layout" xsi:type="array">
<item name="type" xsi:type="string">tabs</item>
<item name="navContainerName" xsi:type="string">left</item>
</item>
<item name="buttons" xsi:type="array">
<item name="back" xsi:type="string">MyModuleAgencyBlockAdminhtmlAgencyEditBackButton</item>
<item name="delete" xsi:type="string">MyModuleAgencyBlockAdminhtmlAgencyEditDeleteButton</item>
<item name="reset" xsi:type="string">MyModuleAgencyBlockAdminhtmlAgencyEditResetButton</item>
<item name="save" xsi:type="string">MyModuleAgencyBlockAdminhtmlAgencyEditSaveButton</item>
<item name="save_and_continue" xsi:type="string">MyModuleAgencyBlockAdminhtmlAgencyEditSaveAndContinueButton</item>
</item>
<item name="reverseMetadataMerge" xsi:type="boolean">true</item>
</argument>
<dataSource name="my_component_form_data_source">
<argument name="dataProvider" xsi:type="configurableObject">
<argument name="class" xsi:type="string">MyModuleAgencyUiComponentEditForm</argument>
<argument name="name" xsi:type="string">my_component_form_data_source</argument>
<argument name="primaryFieldName" xsi:type="string">agency_id</argument>
<argument name="requestFieldName" xsi:type="string">agency_id</argument>
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="submit_url" xsi:type="url" path="my_component/agency/save"/>
</item>
</argument>
</argument>
<argument name="data" xsi:type="array">
<item name="js_config" xsi:type="array">
<item name="component" xsi:type="string">Magento_Ui/js/form/provider</item>
</item>
</argument>
</dataSource>
Last tab is added with Modifier class (like Related product), and my adminhtml/di.xml file looks like:
<virtualType name="MyModuleAgencyUiComponentEditModifierPool" type="MagentoUiDataProviderModifierPool">
<arguments>
<argument name="modifiers" xsi:type="array">
<item name="availability" xsi:type="array">
<item name="class" xsi:type="string">MyModuleAgencyUiComponentEditModifierUnavailableProducts</item>
<item name="sortOrder" xsi:type="number">200</item>
</item>
</argument>
</arguments>
</virtualType>
<type name="MyModuleAgencyUiComponentEditForm">
<arguments>
<argument name="pool" xsi:type="object">MyModuleAgencyUiComponentEditModifierPool</argument>
</arguments>
</type>
<type name="MyModuleAgencyUiComponentEditModifierUnavailableProducts">
<arguments>
<argument name="scopeName" xsi:type="string">my_component_form.areas</argument>
</arguments>
</type>
My getMeta method on DataProvider class (Form) is:
public function getMeta()
{
$meta = parent::getMeta();
/** @var ModifierInterface $modifier */
foreach ($this->pool->getModifiersInstances() as $modifier) {
$meta = $modifier->modifyMeta($meta);
}
return $meta;
}
And last part -> my modifier class extends Related products class, and field construction looks like:
class UnavailableProducts extends Related
{
...
...
...
/**
* {@inheritdoc}
*/
protected function getButtonSet(Phrase $content, Phrase $buttonTitle, $scope)
{
$config = parent::getButtonSet($content, $buttonTitle, $scope);
$modalTarget = $this->scopeName . '.' . 'unavailable' . '.' . $scope . '.modal';
// We need to update some button config in order to make sure that the modal box is linked to the proper button
$config['children']['button_' . $scope]['arguments']['data']['config']['actions'][0]['targetName'] = $modalTarget;
$config['children']['button_' . $scope]['arguments']['data']['config']['actions'][1]['targetName'] = $modalTarget . '.' . $scope . '_product_listing';
return $config;
}
public function modifyMeta(array $meta)
{
$meta = array_replace_recursive(
$meta,
[
// Let's add a new fieldset group
static::EASYCORE_AGENCY => [
'children' => [
'button_set' => $this->getButtonSet(
__('Products that are present here are not available for this agency'),
__('Add Unavailable Products'),
$this->scopePrefix . 'unavailable'
),
'modal' => $this->getGenericModal(
__('Add Unavailable Products'),
$this->scopePrefix . 'unavailable'
),
'unavailable' => $this->getGrid('unavailable')
],
'arguments' => [
'data' => [
'config' => [
'label' => __('Unavailable products'),
'collapsible' => false,
'componentType' => Fieldset::NAME,
'dataScope' => static::DATA_SCOPE,
'sortOrder' => 200
],
],
],
],
]
);
return $meta;
}
If we take a look inside Related class we will see that on grid config there is value like:
'links' => [
'insertData' => '${ $.provider }:${ $.dataProvider }'
],
I suspect that the problem is somewhere on grid or dynamic row configuration... But I am unable to find it on my own :/ Any help would be great.
magento2 grid modal dynamic-rows
I am working on magento 2.1 backend module. Basically backend part is a form that contain tabs. I ahve here some standard inputs but also some dynamic rows etc. Everything is working fine except the last tab. Last tab is a MODAL that allow us to choose products that will not be available for the entity that we are editing/creating.
Basically idea of working is exactly same as on product edit form for related products, so: we have a button "Add related products", modal render with grid of products then we can select them and after click "Add selected products" we have them rendered in dynamic grid rows.
I was able to reproduce some part of this logic on my custom form:
- custom tab with button "Add unavailable products"
- after click modal render
- inside modal I have a product list
- when selecting product and clicking "Add selected products" modal disappear
- when opening modal again the list is filtered (does not contain previously selected elements)
- DYNAMIC GRID is not populated :(
I do not know where is the problem with dynamic grid :/ there are no errors in the console, no error logs, etc. Does anyone worked with those components or maybe have a idea what to do to make it works?
I saw some referrences into this doc:
http://devdocs.magento.com/guides/v2.1/ui-components/ui_dynamic_rows.html
but it is not working :/
This is how the tab looks like:
Some implementation details:
Main form is declared on adminhtml/ui_component/my_component_form.xml and looks like this:
<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">my_component_form.my_component_form_data_source</item>
<item name="deps" xsi:type="string">my_component_form.my_component_form_data_source</item>
<item name="namespace" xsi:type="string">my_component_form</item>
</item>
<item name="label" xsi:type="string" translate="true">Agency Information</item>
<item name="layout" xsi:type="array">
<item name="type" xsi:type="string">tabs</item>
<item name="navContainerName" xsi:type="string">left</item>
</item>
<item name="buttons" xsi:type="array">
<item name="back" xsi:type="string">MyModuleAgencyBlockAdminhtmlAgencyEditBackButton</item>
<item name="delete" xsi:type="string">MyModuleAgencyBlockAdminhtmlAgencyEditDeleteButton</item>
<item name="reset" xsi:type="string">MyModuleAgencyBlockAdminhtmlAgencyEditResetButton</item>
<item name="save" xsi:type="string">MyModuleAgencyBlockAdminhtmlAgencyEditSaveButton</item>
<item name="save_and_continue" xsi:type="string">MyModuleAgencyBlockAdminhtmlAgencyEditSaveAndContinueButton</item>
</item>
<item name="reverseMetadataMerge" xsi:type="boolean">true</item>
</argument>
<dataSource name="my_component_form_data_source">
<argument name="dataProvider" xsi:type="configurableObject">
<argument name="class" xsi:type="string">MyModuleAgencyUiComponentEditForm</argument>
<argument name="name" xsi:type="string">my_component_form_data_source</argument>
<argument name="primaryFieldName" xsi:type="string">agency_id</argument>
<argument name="requestFieldName" xsi:type="string">agency_id</argument>
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="submit_url" xsi:type="url" path="my_component/agency/save"/>
</item>
</argument>
</argument>
<argument name="data" xsi:type="array">
<item name="js_config" xsi:type="array">
<item name="component" xsi:type="string">Magento_Ui/js/form/provider</item>
</item>
</argument>
</dataSource>
Last tab is added with Modifier class (like Related product), and my adminhtml/di.xml file looks like:
<virtualType name="MyModuleAgencyUiComponentEditModifierPool" type="MagentoUiDataProviderModifierPool">
<arguments>
<argument name="modifiers" xsi:type="array">
<item name="availability" xsi:type="array">
<item name="class" xsi:type="string">MyModuleAgencyUiComponentEditModifierUnavailableProducts</item>
<item name="sortOrder" xsi:type="number">200</item>
</item>
</argument>
</arguments>
</virtualType>
<type name="MyModuleAgencyUiComponentEditForm">
<arguments>
<argument name="pool" xsi:type="object">MyModuleAgencyUiComponentEditModifierPool</argument>
</arguments>
</type>
<type name="MyModuleAgencyUiComponentEditModifierUnavailableProducts">
<arguments>
<argument name="scopeName" xsi:type="string">my_component_form.areas</argument>
</arguments>
</type>
My getMeta method on DataProvider class (Form) is:
public function getMeta()
{
$meta = parent::getMeta();
/** @var ModifierInterface $modifier */
foreach ($this->pool->getModifiersInstances() as $modifier) {
$meta = $modifier->modifyMeta($meta);
}
return $meta;
}
And last part -> my modifier class extends Related products class, and field construction looks like:
class UnavailableProducts extends Related
{
...
...
...
/**
* {@inheritdoc}
*/
protected function getButtonSet(Phrase $content, Phrase $buttonTitle, $scope)
{
$config = parent::getButtonSet($content, $buttonTitle, $scope);
$modalTarget = $this->scopeName . '.' . 'unavailable' . '.' . $scope . '.modal';
// We need to update some button config in order to make sure that the modal box is linked to the proper button
$config['children']['button_' . $scope]['arguments']['data']['config']['actions'][0]['targetName'] = $modalTarget;
$config['children']['button_' . $scope]['arguments']['data']['config']['actions'][1]['targetName'] = $modalTarget . '.' . $scope . '_product_listing';
return $config;
}
public function modifyMeta(array $meta)
{
$meta = array_replace_recursive(
$meta,
[
// Let's add a new fieldset group
static::EASYCORE_AGENCY => [
'children' => [
'button_set' => $this->getButtonSet(
__('Products that are present here are not available for this agency'),
__('Add Unavailable Products'),
$this->scopePrefix . 'unavailable'
),
'modal' => $this->getGenericModal(
__('Add Unavailable Products'),
$this->scopePrefix . 'unavailable'
),
'unavailable' => $this->getGrid('unavailable')
],
'arguments' => [
'data' => [
'config' => [
'label' => __('Unavailable products'),
'collapsible' => false,
'componentType' => Fieldset::NAME,
'dataScope' => static::DATA_SCOPE,
'sortOrder' => 200
],
],
],
],
]
);
return $meta;
}
If we take a look inside Related class we will see that on grid config there is value like:
'links' => [
'insertData' => '${ $.provider }:${ $.dataProvider }'
],
I suspect that the problem is somewhere on grid or dynamic row configuration... But I am unable to find it on my own :/ Any help would be great.
magento2 grid modal dynamic-rows
magento2 grid modal dynamic-rows
edited Nov 23 '16 at 13:52
Marius♦
167k28319683
167k28319683
asked Nov 23 '16 at 13:28
Arek T.Arek T.
9617
9617
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Looks like dynamicRows dataScope & dataProvider is wrong. I faced same problem. After changing dataScope & dataProvider grid is populated.
<dynamicRows name="orders">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="dataScope" xsi:type="string">data.orders_tab.links</item>
<item name="dataProvider" xsi:type="string">data.orders_tab.my_module_sales_order_listing</item>
</item>
</argument>
<container name="record"/>
Before:
<item name="dataScope" xsi:type="string">data.links</item>
After:
<item name="dataScope" xsi:type="string">data.orders_tab.links</item>
orders_tab is name of tab where are dynamicRows & insertListing placed.
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%2f147180%2fmagento-2-dynamic-rows-based-on-related-products-modal-grid-on-custom-form-wit%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
Looks like dynamicRows dataScope & dataProvider is wrong. I faced same problem. After changing dataScope & dataProvider grid is populated.
<dynamicRows name="orders">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="dataScope" xsi:type="string">data.orders_tab.links</item>
<item name="dataProvider" xsi:type="string">data.orders_tab.my_module_sales_order_listing</item>
</item>
</argument>
<container name="record"/>
Before:
<item name="dataScope" xsi:type="string">data.links</item>
After:
<item name="dataScope" xsi:type="string">data.orders_tab.links</item>
orders_tab is name of tab where are dynamicRows & insertListing placed.
add a comment |
Looks like dynamicRows dataScope & dataProvider is wrong. I faced same problem. After changing dataScope & dataProvider grid is populated.
<dynamicRows name="orders">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="dataScope" xsi:type="string">data.orders_tab.links</item>
<item name="dataProvider" xsi:type="string">data.orders_tab.my_module_sales_order_listing</item>
</item>
</argument>
<container name="record"/>
Before:
<item name="dataScope" xsi:type="string">data.links</item>
After:
<item name="dataScope" xsi:type="string">data.orders_tab.links</item>
orders_tab is name of tab where are dynamicRows & insertListing placed.
add a comment |
Looks like dynamicRows dataScope & dataProvider is wrong. I faced same problem. After changing dataScope & dataProvider grid is populated.
<dynamicRows name="orders">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="dataScope" xsi:type="string">data.orders_tab.links</item>
<item name="dataProvider" xsi:type="string">data.orders_tab.my_module_sales_order_listing</item>
</item>
</argument>
<container name="record"/>
Before:
<item name="dataScope" xsi:type="string">data.links</item>
After:
<item name="dataScope" xsi:type="string">data.orders_tab.links</item>
orders_tab is name of tab where are dynamicRows & insertListing placed.
Looks like dynamicRows dataScope & dataProvider is wrong. I faced same problem. After changing dataScope & dataProvider grid is populated.
<dynamicRows name="orders">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="dataScope" xsi:type="string">data.orders_tab.links</item>
<item name="dataProvider" xsi:type="string">data.orders_tab.my_module_sales_order_listing</item>
</item>
</argument>
<container name="record"/>
Before:
<item name="dataScope" xsi:type="string">data.links</item>
After:
<item name="dataScope" xsi:type="string">data.orders_tab.links</item>
orders_tab is name of tab where are dynamicRows & insertListing placed.
answered Dec 26 '18 at 13:19
lateNIGHTlateNIGHT
111
111
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%2f147180%2fmagento-2-dynamic-rows-based-on-related-products-modal-grid-on-custom-form-wit%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