I have created a custom module and have used UI component to display store view field in Form page.
I am facing this issue only in Production Mode.
When I open the Edit form page the Store View UI component does not show with selected value.
I checked the Data Provider class with logs and data is getting loaded.
Store View Ui Component Screenshot
Data Provide Class:
<?php
declare(strict_types=1);
namespace VendorHomePageModel;
use MagentoUiDataProviderAbstractDataProvider;
use VendorHomePageModelResourceModelDynamicHomePageBlockCollectionFactory;
use MagentoFrameworkAppRequestInterface;
use PsrLogLoggerInterface;
class DataProvider extends AbstractDataProvider
{
/**
* @var array
*/
public $loadedData;
/**
* @param string $name
* @param string $primaryFieldName
* @param string $requestFieldName
* @param CollectionFactory $collectionFactory
* @param RequestInterface $request
* @param array $meta
* @param array $data
*/
public function __construct(
$name,
$primaryFieldName,
$requestFieldName,
protected CollectionFactory $collectionFactory,
protected RequestInterface $request,
LoggerInterface $logger,
array $meta = [],
array $data = []
) {
$this->collection = $collectionFactory->create();
$this->request = $request;
$this->logger = $logger;
parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
}
/**
* Get Data function
*
* @return array
*/
public function getData()
{
$this->logger->info('Data Provider: Get Data:');
if (isset($this->loadedData)) {
// Debug : Row 838
$this->logger->info(__('Data:ISSET:'), $this->loadedData['838']);
return $this->loadedData;
}
$items = $this->collection->getItems();
foreach ($items as $dynamicCollection) {
$data = $dynamicCollection->getData();
$this->loadedData[$dynamicCollection->getId()] = $data;
}
// Debug : Row 838
$this->logger->info(__('Data'), $this->loadedData['838']);
return $this->loadedData;
}
/**
* Get Meta function
*
* @return array
*/
public function getMeta()
{
$meta = parent::getMeta();
return $meta;
}
}
Ui Component
<field name="store_id">
<argument name="data" xsi:type="array">
<item name="options" xsi:type="object">MagentoCmsUiComponentListingColumnCmsOptions</item>
<item name="config" xsi:type="array">
<item name="dataType" xsi:type="string">int</item>
<item name="label" xsi:type="string" translate="true">Store View</item>
<item name="formElement" xsi:type="string">multiselect</item>
<item name="source" xsi:type="string">store_id</item>
<item name="dataScope" xsi:type="string">store_id</item>
<item name="default" xsi:type="string">0</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
</item>
</argument>
</field>