Skip to content

Magento 2.4.6. Can’t display Layout in the adminpage

For some reason on a new page I created on the admin, I can’t pass text to Body.

Is there any way to suggest what I’m missing?

My code:

appcodeDevRestApietcadminhtmlmenu.xml

<?xml version="1.0" encoding="UTF-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Backend:etc/menu.xsd">
    <menu>
        <add id="Dev_RestApi::dev_module" title="Dev Module" module="Dev_RestApi" sortOrder="10" parent="Magento_Backend::content" resource="Dev_RestApi::dev_module"/>
        <add id="Dev_RestApi::dev_module_PriceInfo_Module" title="PriceInfo_Module" module="Dev_RestApi" sortOrder="10" parent="Dev_RestApi::dev_module" action="dev/controller/index" resource="Dev_RestApi::dev_module_PriceInfo_Module"/>
    </menu>
</config>

appcodeDevRestApiviewadminhtmllayouttoken_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">
    <referenceBlock name="page.title">
        <action method="setPageTitle">
            <argument name="title" xsi:type="string">Dev Module</argument>
        </action>
    </referenceBlock>
    <body>
        <referenceContainer name="content">
            <block class="MagentoBackendBlockTemplate" template="Dev_RestApi::form.phtml"/>
        </referenceContainer>
    </body>
</page>

appcodeDevRestApiviewadminhtmltemplatesform.phtml

<p>Some text</p>

appcodeDevRestApiControllerAdminhtmlControllerindex.php

namespace DevRestApiControllerAdminhtmlController;

use MagentoBackendAppAction;
use MagentoBackendAppActionContext;
use MagentoFrameworkViewResultPageFactory;

class Index extends Action
{
    protected $resultPageFactory;

    public function __construct(Context $context, PageFactory $resultPageFactory)
    {
        parent::__construct($context);
        $this->resultPageFactory = $resultPageFactory;
    }

    public function execute()
    {
        $resultPage = $this->resultPageFactory->create();
        $resultPage->getConfig()->getTitle()->prepend(__('Dev Module Page'));

        $block = $resultPage->getLayout()->getBlock('content');
        if ($block) {
            $block->setTemplate('Dev_RestApi::form.phtml');
        }

        return $resultPage;
    }
}

See only title