In my Form UIComponent only a spinner is showing. I compared my implementation to several ways it is implemented. The grid is showing just fine, i only have the problem in the form.
My layout file:
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<uiComponent name="offertool_offer_form"/>
</referenceContainer>
</body>
</page>
My offertool_offer_form.xml:
<?xml version="1.0"?>
<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">remklov_offertool_form.offer_form_data_source</item>
<item name="deps" xsi:type="string">remklov_offertool_form.offer_form_data_source</item>
</item>
<item name="label" translate="true" xsi:type="string">General Information</item>
<item name="config" xsi:type="array">
<item name="dataScope" xsi:type="string">data</item>
<item name="namespace" xsi:type="string">offertool_offer_form</item>
</item>
<item name="template" xsi:type="string">templates/form/collapsible</item>
</argument>
<dataSource name="offer_form_data_source">
<argument name="dataProvider" xsi:type="configurableObject">
<argument name="class" xsi:type="string">Remklov\OfferTool\Ui\DataProvider\Form\OfferDataProvider</argument>
<argument name="name" xsi:type="string">offer_form_data_source</argument>
<argument name="primaryFieldName" xsi:type="string">entity_id</argument>
<argument name="requestFieldName" xsi:type="string">entity_id</argument>
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="submit_url" path="*/*/save" xsi:type="url"/>
</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>
<fieldset name="General">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="label" xsi:type="string"/>
</item>
</argument>
<field name="quote_id">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="dataType" xsi:type="string">text</item>
<item name="label" translate="true" xsi:type="string">Quote ID</item>
<item name="formElement" xsi:type="string">input</item>
<item name="source" xsi:type="string">Offer</item>
<item name="sortOrder" xsi:type="number">10</item>
<item name="dataScope" xsi:type="string">quote_id</item>
</item>
</argument>
</field>
</fieldset>
</form>
My DataProvider.php
<?php
namespace Remklov\OfferTool\Ui\DataProvider\Form;
use Magento\Framework\App\Request\DataPersistorInterface;
use Remklov\OfferTool\Model\ResourceModel\Offer\CollectionFactory;
class OfferDataProvider extends \Magento\Ui\DataProvider\AbstractDataProvider
{
/**
* @var CollectionFactory $collection
*/
protected $collection;
/**
* @var $_loadedData
*/
protected $_loadedData;
public function __construct(
$name,
$primaryFieldName,
$requestFieldName,
CollectionFactory $collectionFactory,
array $meta = [],
array $data = []
)
{
$this->collection = $collectionFactory->create();
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 $model) {
$this->_loadedData[$model->getId()] = $model->getData();
}
return $this->_loadedData;
}
}
My di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<!-- OFFER DATA PROVIDER -->
<preference for="Remklov\OfferTool\Api\OfferRepositoryInterface" type="Remklov\OfferTool\Model\OfferRepository"/>
<preference for="Remklov\OfferTool\Api\Data\OfferInterface" type="Remklov\OfferTool\Model\Offer"/>
<preference for="Remklov\OfferTool\Api\Data\OfferSearchResultsInterface" type="Magento\Framework\Api\SearchResults"/>
<type name="Remklov\OfferTool\Model\ResourceModel\Offer\Grid\Collection">
<arguments>
<argument name="mainTable" xsi:type="string">offer_entity</argument>
<argument name="model" xsi:type="string">Magento\Framework\View\Element\UiComponent\DataProvider\Document</argument>
<argument name="resourceModel" xsi:type="string">Remklov\OfferTool\Model\ResourceModel\Offer\Grid\Collection</argument>
</arguments>
</type>
<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
<arguments>
<argument name="collections" xsi:type="array">
<item name="offer_grid_data_source" xsi:type="string">Remklov\OfferTool\Model\ResourceModel\Offer\Grid\Collection</item>
</argument>
</arguments>
</type>
</config>
If i print the array of returned data, this is the result:
Array
(
[1] => Array
(
[entity_id] => 1
[previous_id] =>
[increment_id] =>
[quote_id] => 36
[sales_staff_id] => 1
[created_at] => 2019-07-06 14:40:10
[updated_at] => 2019-07-06 14:40:10
)
)
I get no error, and just the page title (and if added the buttons) are shown.