I have a custom module with an admin controller, but when I try to access from the administration page I get the following error:
My controller is in Controller/Adminhtml/Login/Index.php
class Index extends \Magento\Backend\App\Action {...}
and the route decalaration in etc/adminhtml/routes.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="admin">
<route id="oct" frontName="oct">
<module name="Oct_Oct" before="Magento_Backend" />
</route>
</router>
</config>
the layout is in view\adminhtml\layout\oct_login_index.html
<?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">
<block class="oct\oct\Block\Adminhtml\Login\Index" name="oct_login_login" template="login.phtml"/>
</referenceContainer>
</body>
</page>
when i put the cursor on the adminhtml link get:
https://store.com/administrador55/oct/login/index/key/526f769ae4f621ffbda151c2a48015933d510d2d64fe2047abc29cbc29c27e27/
Debug:
any idea?
Thnks
5 Answers 5
Please Replace your oct_login_index.xml with this code
<?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">
<block class="oct\oct\Block\Adminhtml\Login\Index" name="oct_login_login" template="vendor_module::login.phtml"/>
</referenceContainer>
</body>
</page>
In above code i have added vendor_module.You should provide vendor_module to point your file in template where you define your phtml file.
-
Helped @keval KadiyaHimmat Paliwal– Himmat Paliwal2023年05月17日 16:20:26 +00:00Commented May 17, 2023 at 16:20
I have finally found the solution.
The mistake was that i had the module folder like:
../code/Oct/oct
I changed it for
../code/Oct/Oct
and everything works correctly.
Thank you very much everyone for your help and answers
-
where did you find that?jibin george– jibin george2020年06月30日 15:55:39 +00:00Commented Jun 30, 2020 at 15:55
This could be the max_input_vars problem but without seeing more of your code I am not sure.
Set max_input_vars to 10000 in php.ini and restart your web server (or php-fpm) and then give it another go.
-
I have max_input_vars = 100000Miguel– Miguel2020年01月22日 10:23:53 +00:00Commented Jan 22, 2020 at 10:23
Below solution is worked for me:
app\code\Vendor\Module\etc\adminhtml\routes.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="admin">
<route id="oct" frontName="oct">
<module name="Vendor_Module" before="Magento_Backend" />
</route>
</router>
</config>
app\code\Vendor\Module\view\adminhtml\layout\oct_login_index.xml
<?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">
<block class="Vendor\Module\Block\Adminhtml\Login\Index" name="oct_login_login" template="Vendor_Module::login.phtml"/>
</referenceContainer>
</body>
</page>
Here block class Vendor\Module\Block\Adminhtml\Login\Index should extends Magento\Backend\Block\Template.
app\code\Vendor\Module\Controller\Adminhtml\Login\Index.php
<?php
namespace Vendor\Module\Controller\Adminhtml\Login;
class Index extends \Magento\Backend\App\Action
{
/**
* @var \Magento\Framework\View\Result\PageFactory
*/
protected $resultPageFactory;
/**
* @param \Magento\Backend\App\Action\Context $context
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
*/
public function __construct(
\Magento\Backend\App\Action\Context $context,
\Magento\Framework\View\Result\PageFactory $resultPageFactory
) {
parent::__construct($context);
$this->resultPageFactory = $resultPageFactory;
}
/**
* @return \Magento\Backend\Model\View\Result\Page
*/
public function execute()
{
$resultPage = $this->resultPageFactory->create();
$resultPage->addBreadcrumb(__('Test Page'), __('Test Page'));
$resultPage->getConfig()->getTitle()->prepend(__('Test Page'));
return $resultPage;
}
}
app\code\Vendor\Module\view\adminhtml\templates\login.phtml
Add your content here
Then Final result will be:
You need to debug this to get where the issue is . Open in your local envoirment
vendor/magento/module-backend/App/Action/Plugin/Authentication.php vendor/magento/module-backend/App/AbstractAction.php
and add this :
$backtrace = [];
$debugBackTrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
foreach ($debugBackTrace as $item) {
$backtrace[] = @$item['class'] . @$item['type'] . @$item['function'] . "\n";
}
$writer = new \Zend\Log\Writer\Stream(BP . '/var/log/invalid_form_key.log');
$logger = new \Zend\Log\Logger();
$logger->addWriter($writer);
$logger->info(__FUNCTION__);
$logger->info($backtrace);
$logger->info('***************************************************************');
Check the result it here /var/log/invalid_form_key.log .
-
Do I have to do something after writing this code? or will it work directly?Miguel– Miguel2020年01月22日 11:25:20 +00:00Commented Jan 22, 2020 at 11:25
-
no just paste the code , this is an example dev\tests\api-functional\framework\Magento\TestFramework\TestCase\Webapi\Adapter\Rest\DocumentationGenerator.php of using debugtrace method. In the moment you replicate the issue with form key , check if the log will be updatedYlgen Guxholli– Ylgen Guxholli2020年01月22日 11:33:15 +00:00Commented Jan 22, 2020 at 11:33
-
Explore related questions
See similar questions with these tags.
ui_componentCan you please update the code here?