0

I have created listing & it's working fine with database.

Now i'm trying to create "Add Form" for that.

{folder path}\magento2\app\code\Custom\Module\Controller\Adminhtml\Posts\NewAction.php

namespace Custom\Module\Controller\Adminhtml\Posts;

use Magento\Framework\View\Result\PageFactory;
use Magento\Framework\App\Action\Context;

class NewAction extends \Magento\Framework\App\Action\Action {

    /**
     * @var \Magento\Framework\Controller\Result\ForwardFactory
     */
    protected $resultPageFactory;

    /**
     * @param \Magento\Framework\App\Action\Context $context
     * @param \Magento\Framework\Controller\Result\ForwardFactory $resultForwardFactory
     */
    public function __construct(
    \Magento\Framework\App\Action\Context $context, \Magento\Framework\View\Result\PageFactory $resultPageFactory
    ) {
        $this->resultPageFactory = $resultPageFactory;
        parent::__construct($context);
    }
    /**
     * {@inheritdoc}
     */
    protected function _isAllowed() {
        return $this->_authorization->isAllowed('Custom_Module::save');
    }

    /**
     * Forward to edit
     *
     * @return \Magento\Backend\Model\View\Result\Forward
     */
    public function execute() {
        /** @var \Magento\Backend\Model\View\Result\Forward $resultForward */
        $resultForward = $this->resultForwardFactory->create();
        return $resultForward->forward('edit');
    }
}

It's giving below error.

1 exception(s): Exception #0 (Exception): Recoverable Error: Argument 1 passed to Custom\Module\Controller\Adminhtml\Posts\NewAction::__construct() must be an instance of Magento\Framework\App\Action\Context, none given, called in {folder path}\magento2\var\generation\Custom\Module\Controller\Adminhtml\Posts\NewAction\Interceptor.php on line 14 and defined in {folder path}\magento2\app\code\Custom\Module\Controller\Adminhtml\Posts\NewAction.php on line 20

3

0