In the product form I want to add dependency button with customizable options values, for this I am adding below function by overriding the customoptions data-provider file :
protected function getIsdependFieldConfig($sortOrder)
{ //FIELD_DEPEND_NAME
$modalTarget = 'product_form.product_form.' . static::GROUP_DEPENDS . '.' . $this->dataScopeName . '.modal';
$content= __(
''
);
return [
/*'children' => [
'modal' => $this->getGenericModal(
$this->scopePrefix . static::DATA_SCOPE_DEPENDS
),
//static::DATA_SCOPE_DEPENDS => $this->getGrid($this->scopePrefix . static::DATA_SCOPE_DEPENDS),
] ,*/
'arguments' => [
'data' => [
'config' => [
'formElement' => 'container',
'componentType' => 'container',
'component' => 'Magento_Ui/js/form/components/button',
'actions' => [
[
'targetName' => $this->dataScopeName . '.dependancyModal',
'actionName' => 'toggleModal',
],
[
'targetName' => $modalTarget . '.' . $this->dataScopeName . '.dependancyModal',
'actionName' => 'render',
],
],
'title' => __('Dependancy'),
'sortOrder' => 60,
],
],
],
];
}
Reference block in the layout file :
<referenceBlock name="product_form">
<block name="customoptions.form.dependant.matrix" class="Magento\ConfigurableProduct\Block\Adminhtml\Product\Edit\Tab\Variations\Config\Matrix" template="Vendor_Namespace::products/assign_products.phtml" as="custom_dependant">
<arguments>
<argument name="config" xsi:type="array">
<item name="collapsible" xsi:type="boolean">false</item>
<item name="label" xsi:type="string" translate="true" />
<item name="sortOrder" xsi:type="string">1000</item>
<item name="canShow" xsi:type="boolean">true</item>
<item name="componentType" xsi:type="string">fieldset</item>
<item name="provider" xsi:type="string">product_form.product_form_data_source</item>
<item name="form" xsi:type="string">product_form.product_form</item>
<item name="modal" xsi:type="string">dependancyModal</item>
<item name="nameStepWizard" xsi:type="string">variation-steps-wizard</item>
<item name="dataScope" xsi:type="string">customoptionsFormDependant</item>
<item name="urlWizard" xsi:type="string">customoptions/items/dependancy</item>
</argument>
</arguments>
</block>
</referenceBlock>
Popup is able to open on click of button but no data and UI component form has render.
Best Answer
Ui Component Form XML: