I have created a UI Component based on the code from Alan Storm’s excellent tutorial. This UI Component displays as expected in pages with dedicated routes.
However, the UI Component will not display in a modal on the Product page in adminhtml. Here is a Modifier for a modal to display the UI Component from the fine tutorial:
<?php
namespace DotancohenFooUiDataProviderProductFormModifier;
use MagentoCatalogModelLocatorLocatorInterface;
use MagentoCatalogUiDataProviderProductFormModifierAbstractModifier;
class Features extends AbstractModifier {
protected $_product;
/**
* @param LocatorInterface $locator
*/
public function __construct(LocatorInterface $locator)
{
$this->_product = $locator->getProduct();
}
public function modifyMeta(array $meta) : array
{
if ( !$this->_product ) {
return $meta;
}
$product_id = $this->_product->getId();
$meta['exclude_modal'] = array (
'arguments' => array (
'data' => array (
'config' => array (
'componentType' => 'modal',
'dataScope' => '',
'provider' => 'product_form.product_form_data_source',
'ns' => 'product_form',
'options' => array (
'title' => 'Configure Particular Foo or Bar', /* How to Display the Foo ID or Bar ID here? */
'buttons' => array (
0 => array (
'text' => 'Save',
'class' => 'action-primary',
'actions' => array (
0 => array (
'targetName' => 'index = product_form',
'actionName' => 'save',
),
1 => 'closeModal',
),
),
),
),
),
),
),
'children' => array (
'modal_content' => array (
'arguments' => array (
'data' => array (
'config' => array (
'autoRender' => false,
'componentType' => 'container',
'dataScope' => 'data.product',
'externalProvider' => 'data.product_data_source',
'ns' => 'product_form',
'render_url' => 'https://example.com/admin/mui/index/render/key/123abc/',
'realTimeLink' => true,
'behaviourType' => 'edit',
'externalFilterMode' => true,
'currentProductId' => $product_id,
),
),
),
'children' => array (
'modal-fieldset' => array (
'arguments' => array (
'data' => array (
'config' => array (
'label' => 'Fieldset',
'componentType' => 'fieldset',
'dataScope' => 'foos_features',
'collapsible' => true,
'sortOrder' => 10,
'opened' => true,
),
),
),
'children' => array (
/* These "Features" will be different for each Foo and Bar! How to get the Foo or Bar ID to invoke a method which will return the proper data? */
'first_feature' => array (
'arguments' => array (
'data' => array (
'config' => array (
'label' => 'Feature the first',
'dataScope' => 'first_feature',
'componentType' => 'pulsestorm_simple',
'sortOrder' => 10,
),
),
),
),
'second_feature' => array (
'arguments' => array (
'data' => array (
'config' => array (
'label' => 'Feature the second',
'dataScope' => 'second_feature',
'componentType' => 'field',
'dataType' => 'text',
'formElement' => 'checkbox',
'valueMap' => array (
'true' => '1',
'false' => '0',
),
'sortOrder' => 20,
),
),
),
),
),
),
),
),
),
);
return $meta;
}
}
I suspect that the problem is that I do not know what values to use for the component’s dataType
or formElement
in the config
array, so I do not have these values configured.
Where are the dataType
, formElement
, and other config
array keys documented? I see no mention of them in the fine manual. Furthermore, is this in fact the problem? What else might be?