2 deleted 82 characters in body
source | link

Finally I got the solution I just need to set store id in DataProvider file like below.

I hope it'll be helpful for others. Happy Coding :)

Finally I got the solution I just need to set store id in DataProvider file like below.

I hope it'll be helpful for others. Happy Coding :)

I just need to set store id in DataProvider file like below.

1
source | link

Finally I got the solution I just need to set store id in DataProvider file like below.

<?php
namespace Vendor\Module\Model\Providers;
use Vendor\Module\Model\ResourceModel\Company\CollectionFactory;

class DataProvider extends \Magento\Ui\DataProvider\AbstractDataProvider
{
    /**
     * @var array
     */
    protected $loadedData;

    /**
     * @param string $name
     * @param string $primaryFieldName
     * @param string $requestFieldName
     * @param CollectionFactory $taskCollectionFactory
     * @param array $meta
     * @param array $data
     */
    public function __construct(
        $name,
        $primaryFieldName,
        $requestFieldName,
        CollectionFactory $companyCollectionFactory,
        \Magento\Framework\App\Request\Http $request, 
        \Magento\Store\Api\StoreRepositoryInterface $storeRepository,        
        array $meta = [],
        array $data = []
    ) {
        $this->collection = $companyCollectionFactory->create();
        $this->request = $request;
        parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
    }

    /**
     * Get data
     *
     * @return array
     */
    public function getData()
    {
        if (isset($this->loadedData)) {
            return $this->loadedData;
        }
        $items = $this->collection->getItems();
        foreach ($items as $item) { 
            $item->setStoreId($this->request->getParam('store'));
            $this->loadedData[$item->getEntityId()] = $item->getData();
        } 

        return $this->loadedData;
    }
}

ui_form.xml

<field name="store_id" sortOrder="65" formElement="hidden">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="source" xsi:type="string">company</item>
            </item>
        </argument>
        <settings>
            <dataType>hidden</dataType>
            <dataScope>store_id</dataScope>
        </settings>
</field>

I hope it'll be helpful for others. Happy Coding :)