Magento226: Fatal error Call to a member function setId()

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
2
down vote

favorite












I am getting this error in magento Ui component admin form , it tried changing container instead of form in Ui form , but that did not help either.




Fatal error: Method MagentoUiTemplateEngineXhtmlResult::__toString() must not throw an exception, caught Error: Call to a member function setId() on boolean in /opt/lampp/htdocs/Magentos226/vendor/magento/module-ui/Component/Wrapper/UiComponent.php on line 0




DataSource in Ui Form



<dataSource name="item_form_data_source">
<argument name="dataProvider" xsi:type="configurableObject">
<argument name="class" xsi:type="string">VendorModuleModelItemDataProvider</argument>
<argument name="name" xsi:type="string">igallery_form_data_source</argument>
<argument name="primaryFieldName" xsi:type="string">id</argument>
<argument name="requestFieldName" xsi:type="string">id</argument>
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="submit_url" xsi:type="url" path="module/item/save"/>
</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>


Media Uploader Code in Ui Form



<htmlContent name="gallery" sortOrder="22">
<argument name="data" xsi:type="array">
<item name="wrapper" xsi:type="array">
<item name="label" xsi:type="string" translate="true"> Images</item>
<item name="collapsible" xsi:type="boolean">true</item>
<item name="opened" xsi:type="boolean">true</item>
</item>
</argument>
<settings>
<wrapper>
<canShow>true</canShow>
<componentType>fieldset</componentType>
</wrapper>
</settings>
<block name="gallery" class="VendorModuleBlockAdminhtmlMediaHelperFormGallery">
<block class="VendorEventsBlockAdminhtmlMediaHelperFormGalleryImage" as="content">
<arguments>
<argument name="config" xsi:type="array">
<item name="parentComponent" xsi:type="string">module_article_form.module_article_form.block_gallery.block_gallery</item>
</argument>
</arguments>
</block>
</block>
</htmlContent>


DataProvider



<?php

namespace VendorModuleModelItem;

use VendorModuleModelResourceModelItemCollectionFactory;
use MagentoFrameworkAppRequestDataPersistorInterface;

class DataProvider extends MagentoUiDataProviderAbstractDataProvider

protected $collection;
protected $dataPersistor;
public $_storeManager;
protected $loadedData;

public function __construct(
$name,
$primaryFieldName,
$requestFieldName,
CollectionFactory $blockCollectionFactory,
DataPersistorInterface $dataPersistor,
MagentoStoreModelStoreManagerInterface $storeManager,
array $meta = ,
array $data =
)
$this->collection = $blockCollectionFactory->create();
$this->_storeManager=$storeManager;
$this->dataPersistor = $dataPersistor;
parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);


public function getData()

if (isset($this->loadedData))
return $this->loadedData;

$items = $this->collection->getItems();

foreach ($items as $page)
$this->loadedData[$page->getId()] = $page->getData();


$data = $this->dataPersistor->get('media-item');
if (!empty($data))
$page = $this->collection->getNewEmptyItem();
$page->setData($data);
$this->loadedData[$page->getId()] = $page->getData();
$this->dataPersistor->clear('media-item');


return $this->loadedData;











share|improve this question



















  • 2




    share your code
    – Ranjit Shinde
    3 hours ago










  • Ranjit Shinde relevant code is added please check
    – Verdu
    1 hour ago
















up vote
2
down vote

favorite












I am getting this error in magento Ui component admin form , it tried changing container instead of form in Ui form , but that did not help either.




Fatal error: Method MagentoUiTemplateEngineXhtmlResult::__toString() must not throw an exception, caught Error: Call to a member function setId() on boolean in /opt/lampp/htdocs/Magentos226/vendor/magento/module-ui/Component/Wrapper/UiComponent.php on line 0




DataSource in Ui Form



<dataSource name="item_form_data_source">
<argument name="dataProvider" xsi:type="configurableObject">
<argument name="class" xsi:type="string">VendorModuleModelItemDataProvider</argument>
<argument name="name" xsi:type="string">igallery_form_data_source</argument>
<argument name="primaryFieldName" xsi:type="string">id</argument>
<argument name="requestFieldName" xsi:type="string">id</argument>
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="submit_url" xsi:type="url" path="module/item/save"/>
</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>


Media Uploader Code in Ui Form



<htmlContent name="gallery" sortOrder="22">
<argument name="data" xsi:type="array">
<item name="wrapper" xsi:type="array">
<item name="label" xsi:type="string" translate="true"> Images</item>
<item name="collapsible" xsi:type="boolean">true</item>
<item name="opened" xsi:type="boolean">true</item>
</item>
</argument>
<settings>
<wrapper>
<canShow>true</canShow>
<componentType>fieldset</componentType>
</wrapper>
</settings>
<block name="gallery" class="VendorModuleBlockAdminhtmlMediaHelperFormGallery">
<block class="VendorEventsBlockAdminhtmlMediaHelperFormGalleryImage" as="content">
<arguments>
<argument name="config" xsi:type="array">
<item name="parentComponent" xsi:type="string">module_article_form.module_article_form.block_gallery.block_gallery</item>
</argument>
</arguments>
</block>
</block>
</htmlContent>


DataProvider



<?php

namespace VendorModuleModelItem;

use VendorModuleModelResourceModelItemCollectionFactory;
use MagentoFrameworkAppRequestDataPersistorInterface;

class DataProvider extends MagentoUiDataProviderAbstractDataProvider

protected $collection;
protected $dataPersistor;
public $_storeManager;
protected $loadedData;

public function __construct(
$name,
$primaryFieldName,
$requestFieldName,
CollectionFactory $blockCollectionFactory,
DataPersistorInterface $dataPersistor,
MagentoStoreModelStoreManagerInterface $storeManager,
array $meta = ,
array $data =
)
$this->collection = $blockCollectionFactory->create();
$this->_storeManager=$storeManager;
$this->dataPersistor = $dataPersistor;
parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);


public function getData()

if (isset($this->loadedData))
return $this->loadedData;

$items = $this->collection->getItems();

foreach ($items as $page)
$this->loadedData[$page->getId()] = $page->getData();


$data = $this->dataPersistor->get('media-item');
if (!empty($data))
$page = $this->collection->getNewEmptyItem();
$page->setData($data);
$this->loadedData[$page->getId()] = $page->getData();
$this->dataPersistor->clear('media-item');


return $this->loadedData;











share|improve this question



















  • 2




    share your code
    – Ranjit Shinde
    3 hours ago










  • Ranjit Shinde relevant code is added please check
    – Verdu
    1 hour ago












up vote
2
down vote

favorite









up vote
2
down vote

favorite











I am getting this error in magento Ui component admin form , it tried changing container instead of form in Ui form , but that did not help either.




Fatal error: Method MagentoUiTemplateEngineXhtmlResult::__toString() must not throw an exception, caught Error: Call to a member function setId() on boolean in /opt/lampp/htdocs/Magentos226/vendor/magento/module-ui/Component/Wrapper/UiComponent.php on line 0




DataSource in Ui Form



<dataSource name="item_form_data_source">
<argument name="dataProvider" xsi:type="configurableObject">
<argument name="class" xsi:type="string">VendorModuleModelItemDataProvider</argument>
<argument name="name" xsi:type="string">igallery_form_data_source</argument>
<argument name="primaryFieldName" xsi:type="string">id</argument>
<argument name="requestFieldName" xsi:type="string">id</argument>
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="submit_url" xsi:type="url" path="module/item/save"/>
</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>


Media Uploader Code in Ui Form



<htmlContent name="gallery" sortOrder="22">
<argument name="data" xsi:type="array">
<item name="wrapper" xsi:type="array">
<item name="label" xsi:type="string" translate="true"> Images</item>
<item name="collapsible" xsi:type="boolean">true</item>
<item name="opened" xsi:type="boolean">true</item>
</item>
</argument>
<settings>
<wrapper>
<canShow>true</canShow>
<componentType>fieldset</componentType>
</wrapper>
</settings>
<block name="gallery" class="VendorModuleBlockAdminhtmlMediaHelperFormGallery">
<block class="VendorEventsBlockAdminhtmlMediaHelperFormGalleryImage" as="content">
<arguments>
<argument name="config" xsi:type="array">
<item name="parentComponent" xsi:type="string">module_article_form.module_article_form.block_gallery.block_gallery</item>
</argument>
</arguments>
</block>
</block>
</htmlContent>


DataProvider



<?php

namespace VendorModuleModelItem;

use VendorModuleModelResourceModelItemCollectionFactory;
use MagentoFrameworkAppRequestDataPersistorInterface;

class DataProvider extends MagentoUiDataProviderAbstractDataProvider

protected $collection;
protected $dataPersistor;
public $_storeManager;
protected $loadedData;

public function __construct(
$name,
$primaryFieldName,
$requestFieldName,
CollectionFactory $blockCollectionFactory,
DataPersistorInterface $dataPersistor,
MagentoStoreModelStoreManagerInterface $storeManager,
array $meta = ,
array $data =
)
$this->collection = $blockCollectionFactory->create();
$this->_storeManager=$storeManager;
$this->dataPersistor = $dataPersistor;
parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);


public function getData()

if (isset($this->loadedData))
return $this->loadedData;

$items = $this->collection->getItems();

foreach ($items as $page)
$this->loadedData[$page->getId()] = $page->getData();


$data = $this->dataPersistor->get('media-item');
if (!empty($data))
$page = $this->collection->getNewEmptyItem();
$page->setData($data);
$this->loadedData[$page->getId()] = $page->getData();
$this->dataPersistor->clear('media-item');


return $this->loadedData;











share|improve this question















I am getting this error in magento Ui component admin form , it tried changing container instead of form in Ui form , but that did not help either.




Fatal error: Method MagentoUiTemplateEngineXhtmlResult::__toString() must not throw an exception, caught Error: Call to a member function setId() on boolean in /opt/lampp/htdocs/Magentos226/vendor/magento/module-ui/Component/Wrapper/UiComponent.php on line 0




DataSource in Ui Form



<dataSource name="item_form_data_source">
<argument name="dataProvider" xsi:type="configurableObject">
<argument name="class" xsi:type="string">VendorModuleModelItemDataProvider</argument>
<argument name="name" xsi:type="string">igallery_form_data_source</argument>
<argument name="primaryFieldName" xsi:type="string">id</argument>
<argument name="requestFieldName" xsi:type="string">id</argument>
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="submit_url" xsi:type="url" path="module/item/save"/>
</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>


Media Uploader Code in Ui Form



<htmlContent name="gallery" sortOrder="22">
<argument name="data" xsi:type="array">
<item name="wrapper" xsi:type="array">
<item name="label" xsi:type="string" translate="true"> Images</item>
<item name="collapsible" xsi:type="boolean">true</item>
<item name="opened" xsi:type="boolean">true</item>
</item>
</argument>
<settings>
<wrapper>
<canShow>true</canShow>
<componentType>fieldset</componentType>
</wrapper>
</settings>
<block name="gallery" class="VendorModuleBlockAdminhtmlMediaHelperFormGallery">
<block class="VendorEventsBlockAdminhtmlMediaHelperFormGalleryImage" as="content">
<arguments>
<argument name="config" xsi:type="array">
<item name="parentComponent" xsi:type="string">module_article_form.module_article_form.block_gallery.block_gallery</item>
</argument>
</arguments>
</block>
</block>
</htmlContent>


DataProvider



<?php

namespace VendorModuleModelItem;

use VendorModuleModelResourceModelItemCollectionFactory;
use MagentoFrameworkAppRequestDataPersistorInterface;

class DataProvider extends MagentoUiDataProviderAbstractDataProvider

protected $collection;
protected $dataPersistor;
public $_storeManager;
protected $loadedData;

public function __construct(
$name,
$primaryFieldName,
$requestFieldName,
CollectionFactory $blockCollectionFactory,
DataPersistorInterface $dataPersistor,
MagentoStoreModelStoreManagerInterface $storeManager,
array $meta = ,
array $data =
)
$this->collection = $blockCollectionFactory->create();
$this->_storeManager=$storeManager;
$this->dataPersistor = $dataPersistor;
parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);


public function getData()

if (isset($this->loadedData))
return $this->loadedData;

$items = $this->collection->getItems();

foreach ($items as $page)
$this->loadedData[$page->getId()] = $page->getData();


$data = $this->dataPersistor->get('media-item');
if (!empty($data))
$page = $this->collection->getNewEmptyItem();
$page->setData($data);
$this->loadedData[$page->getId()] = $page->getData();
$this->dataPersistor->clear('media-item');


return $this->loadedData;








magento2 uicomponent image-upload ui-form






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 1 hour ago

























asked 4 hours ago









Verdu

979422




979422







  • 2




    share your code
    – Ranjit Shinde
    3 hours ago










  • Ranjit Shinde relevant code is added please check
    – Verdu
    1 hour ago












  • 2




    share your code
    – Ranjit Shinde
    3 hours ago










  • Ranjit Shinde relevant code is added please check
    – Verdu
    1 hour ago







2




2




share your code
– Ranjit Shinde
3 hours ago




share your code
– Ranjit Shinde
3 hours ago












Ranjit Shinde relevant code is added please check
– Verdu
1 hour ago




Ranjit Shinde relevant code is added please check
– Verdu
1 hour ago










1 Answer
1






active

oldest

votes

















up vote
2
down vote



accepted










Check for typo in code make sure your block path is correct VendorModuleNameBlockAdminhtmlMediaHelperFormGalleryImage i check this code it is working for me.



<htmlContent name="gallery" sortOrder="22">
<argument name="data" xsi:type="array">
<item name="wrapper" xsi:type="array">
<item name="label" xsi:type="string" translate="true"> Images</item>
<item name="collapsible" xsi:type="boolean">true</item>
<item name="opened" xsi:type="boolean">true</item>
</item>
</argument>
<settings>
<wrapper>
<canShow>true</canShow>
<componentType>fieldset</componentType>
</wrapper>
</settings>
<block name="gallery" class="VendorModuleBlockAdminhtmlMediaHelperFormGallery">
<block class="VendorEventsBlockAdminhtmlMediaHelperFormGalleryImage" as="content">
<arguments>
<argument name="config" xsi:type="array">
<item name="parentComponent" xsi:type="string">module_article_form.module_article_form.block_gallery.block_gallery</item>
</argument>
</arguments>
</block>
</block>
</htmlContent>





share|improve this answer




















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "479"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f246435%2fmagento226-fatal-error-call-to-a-member-function-setid%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote



    accepted










    Check for typo in code make sure your block path is correct VendorModuleNameBlockAdminhtmlMediaHelperFormGalleryImage i check this code it is working for me.



    <htmlContent name="gallery" sortOrder="22">
    <argument name="data" xsi:type="array">
    <item name="wrapper" xsi:type="array">
    <item name="label" xsi:type="string" translate="true"> Images</item>
    <item name="collapsible" xsi:type="boolean">true</item>
    <item name="opened" xsi:type="boolean">true</item>
    </item>
    </argument>
    <settings>
    <wrapper>
    <canShow>true</canShow>
    <componentType>fieldset</componentType>
    </wrapper>
    </settings>
    <block name="gallery" class="VendorModuleBlockAdminhtmlMediaHelperFormGallery">
    <block class="VendorEventsBlockAdminhtmlMediaHelperFormGalleryImage" as="content">
    <arguments>
    <argument name="config" xsi:type="array">
    <item name="parentComponent" xsi:type="string">module_article_form.module_article_form.block_gallery.block_gallery</item>
    </argument>
    </arguments>
    </block>
    </block>
    </htmlContent>





    share|improve this answer
























      up vote
      2
      down vote



      accepted










      Check for typo in code make sure your block path is correct VendorModuleNameBlockAdminhtmlMediaHelperFormGalleryImage i check this code it is working for me.



      <htmlContent name="gallery" sortOrder="22">
      <argument name="data" xsi:type="array">
      <item name="wrapper" xsi:type="array">
      <item name="label" xsi:type="string" translate="true"> Images</item>
      <item name="collapsible" xsi:type="boolean">true</item>
      <item name="opened" xsi:type="boolean">true</item>
      </item>
      </argument>
      <settings>
      <wrapper>
      <canShow>true</canShow>
      <componentType>fieldset</componentType>
      </wrapper>
      </settings>
      <block name="gallery" class="VendorModuleBlockAdminhtmlMediaHelperFormGallery">
      <block class="VendorEventsBlockAdminhtmlMediaHelperFormGalleryImage" as="content">
      <arguments>
      <argument name="config" xsi:type="array">
      <item name="parentComponent" xsi:type="string">module_article_form.module_article_form.block_gallery.block_gallery</item>
      </argument>
      </arguments>
      </block>
      </block>
      </htmlContent>





      share|improve this answer






















        up vote
        2
        down vote



        accepted







        up vote
        2
        down vote



        accepted






        Check for typo in code make sure your block path is correct VendorModuleNameBlockAdminhtmlMediaHelperFormGalleryImage i check this code it is working for me.



        <htmlContent name="gallery" sortOrder="22">
        <argument name="data" xsi:type="array">
        <item name="wrapper" xsi:type="array">
        <item name="label" xsi:type="string" translate="true"> Images</item>
        <item name="collapsible" xsi:type="boolean">true</item>
        <item name="opened" xsi:type="boolean">true</item>
        </item>
        </argument>
        <settings>
        <wrapper>
        <canShow>true</canShow>
        <componentType>fieldset</componentType>
        </wrapper>
        </settings>
        <block name="gallery" class="VendorModuleBlockAdminhtmlMediaHelperFormGallery">
        <block class="VendorEventsBlockAdminhtmlMediaHelperFormGalleryImage" as="content">
        <arguments>
        <argument name="config" xsi:type="array">
        <item name="parentComponent" xsi:type="string">module_article_form.module_article_form.block_gallery.block_gallery</item>
        </argument>
        </arguments>
        </block>
        </block>
        </htmlContent>





        share|improve this answer












        Check for typo in code make sure your block path is correct VendorModuleNameBlockAdminhtmlMediaHelperFormGalleryImage i check this code it is working for me.



        <htmlContent name="gallery" sortOrder="22">
        <argument name="data" xsi:type="array">
        <item name="wrapper" xsi:type="array">
        <item name="label" xsi:type="string" translate="true"> Images</item>
        <item name="collapsible" xsi:type="boolean">true</item>
        <item name="opened" xsi:type="boolean">true</item>
        </item>
        </argument>
        <settings>
        <wrapper>
        <canShow>true</canShow>
        <componentType>fieldset</componentType>
        </wrapper>
        </settings>
        <block name="gallery" class="VendorModuleBlockAdminhtmlMediaHelperFormGallery">
        <block class="VendorEventsBlockAdminhtmlMediaHelperFormGalleryImage" as="content">
        <arguments>
        <argument name="config" xsi:type="array">
        <item name="parentComponent" xsi:type="string">module_article_form.module_article_form.block_gallery.block_gallery</item>
        </argument>
        </arguments>
        </block>
        </block>
        </htmlContent>






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 14 mins ago









        Addify

        5495




        5495



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f246435%2fmagento226-fatal-error-call-to-a-member-function-setid%23new-answer', 'question_page');

            );

            Post as a guest













































































            Comments

            Popular posts from this blog

            List of Gilmore Girls characters

            What does second last employer means? [closed]

            One-line joke