cancel
Showing results for 
Search instead for 
Did you mean: 

Select All in Block for Controller

SOLVED
   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

Re: Select All in Block for Controller

@Antoine553 remove generation and di folder from var folder, then check it.


Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer

Re: Select All in Block for Controller

i found the solution

<?php
namespace Mymodule\AdminPage\Block\Adminhtml;

use Magento\Backend\Block\Template;

class Contactslist extends \Magento\Backend\Block\Template
{
	
	 public function __construct(
         \Magento\Backend\Block\Template\Context $context,
         \Mymodule\AdminPage\Model\ContactFactory $contactFactory,
         \Magento\Framework\View\Result\PageFactory $resultPageFactory
     ) {
          parent::__construct($context);
          $this->contactFactory = $contactFactory;
          $this->resultPageFactory = $resultPageFactory;
     }
	
	public function mycustom(){
    	echo "test";
	}
	
	/*public function getAll(){
		$data = $this->_objectManager->create('Mymodule\AdminPage\Model\Contact')->getCollection();
		foreach ($data as $d )  {
		        echo $d->getToreplace();
		        echo $d->getReplaceby();
		    }
	}*/
	
	
}

Re: Select All in Block for Controller

Issue was in your block file,

 

Original Class is

\Mymodule\AdminPage\Model\ContactFactory $contactFactory,

 You have kept 

\Mymodule\AdminPage\Model\Contact $contact,

 So you have to keep Factory Object of your Model Class.

 

After Apply ModelFactory You must delete var/generation folder.

If Issue Solved, Click Kudos/Accept As solutions. Get Magento insight from
Magento 2 Blogs/Tutorial