Есть ли способ отладить ошибки, такие как недопустимый тип блока:Magento\Серверная часть\Блок\Пустой\Редактировать\Форма?

magento.stackexchange https://magento.stackexchange.com/questions/116079

  •  29-09-2020
  •  | 
  •  

Вопрос

Существует способ более простой отладки ошибок, таких как недопустимый тип блока:Magento\Серверная часть\Блок\Пустой\Редактировать\Форма?

Я пытаюсь вроде клонирую функциональность модуля module-sales-rule для практики, но я получаю эту ошибку при доступе к моей пользовательской форме.

Invalid block type: Magento\Backend\Block\Empty\Edit\Form
    #0 /var/www/magento2_conector/vendor/magento/framework/View/Layout/Generator/Block.php(237): Magento\Framework\View\Layout\Generator\Block->getBlockInstance('Magento\\Backend...', Array)
    #1 /var/www/magento2_conector/vendor/magento/framework/View/Layout.php(760): Magento\Framework\View\Layout\Generator\Block->createBlock('Magento\\Backend...', 'promo_coupons...', Array)
    #2 /var/www/magento2_conector/vendor/magento/framework/View/Layout.php(743): Magento\Framework\View\Layout->_createBlock('Magento\\Backend...', 'promo_coupons...', Array)
    #3 /var/www/magento2_conector/var/generation/Magento/Framework/View/Layout/Interceptor.php(349): Magento\Framework\View\Layout->createBlock('Magento\\Backend...', 'promo_coupons...', Array)
    #4 /var/www/magento2_conector/vendor/magento/framework/View/Element/AbstractBlock.php(380): Magento\Framework\View\Layout\Interceptor->createBlock('Magento\\Backend...', 'promo_coupons...', Array)
    #5 /var/www/magento2_conector/vendor/magento/module-backend/Block/Widget/Form/Container.php(108): Magento\Framework\View\Element\AbstractBlock->addChild('form', 'Magento\\Backend...')
    #6 /var/www/magento2_conector/vendor/magento/framework/View/Element/AbstractBlock.php(262): Magento\Backend\Block\Widget\Form\Container->_prepareLayout()
    #7 /var/www/magento2_conector/vendor/magento/framework/View/Layout/Generator/Block.php(139): Magento\Framework\View\Element\AbstractBlock->setLayout(Object(Magento\Framework\View\Layout\Interceptor))
    #8 /var/www/magento2_conector/vendor/magento/framework/View/Layout/GeneratorPool.php(86): Magento\Framework\View\Layout\Generator\Block->process(Object(Magento\Framework\View\Layout\Reader\Context), Object(Magento\Framework\View\Layout\Generator\Context))
    #9 /var/www/magento2_conector/vendor/magento/framework/View/Layout.php(327): Magento\Framework\View\Layout\GeneratorPool->process(Object(Magento\Framework\View\Layout\Reader\Context), Object(Magento\Framework\View\Layout\Generator\Context))
    #10 /var/www/magento2_conector/var/generation/Magento/Framework/View/Layout/Interceptor.php(89): Magento\Framework\View\Layout->generateElements()
    #11 /var/www/magento2_conector/vendor/magento/framework/View/Layout/Builder.php(129): Magento\Framework\View\Layout\Interceptor->generateElements()
    #12 /var/www/magento2_conector/vendor/magento/framework/View/Page/Builder.php(55): Magento\Framework\View\Layout\Builder->generateLayoutBlocks()
    #13 /var/www/magento2_conector/vendor/magento/framework/View/Layout/Builder.php(65): Magento\Framework\View\Page\Builder->generateLayoutBlocks()
    #14 /var/www/magento2_conector/vendor/magento/framework/View/Page/Config.php(166): Magento\Framework\View\Layout\Builder->build()
    #15 /var/www/magento2_conector/vendor/magento/framework/View/Page/Config.php(176): Magento\Framework\View\Page\Config->build()
    #16 /var/www/magento2_conector/vendor/magento/framework/View/Result/Page.php(225): Magento\Framework\View\Page\Config->publicBuild()
    #17 /var/www/magento2_conector/vendor/magento/framework/View/Result/Layout.php(162): Magento\Framework\View\Result\Page->render(Object(Magento\Framework\App\Response\Http\Interceptor))
    #18 /var/www/magento2_conector/var/generation/Magento/Backend/Model/View/Result/Page/Interceptor.php(193): Magento\Framework\View\Result\Layout->renderResult(Object(Magento\Framework\App\Response\Http\Interceptor))
    #19 /var/www/magento2_conector/vendor/magento/framework/App/Http.php(119): Magento\Backend\Model\View\Result\Page\Interceptor->renderResult(Object(Magento\Framework\App\Response\Http\Interceptor))
    #20 /var/www/magento2_conector/vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\Http->launch()
    #21 /var/www/magento2_conector/index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))

У меня есть контроллер NewAction.php с его методом execute

public function execute()
    {
        $this->_forward('edit');
    }

А затем мой контроллер Edit.php

public function execute()
    {
        return $this->pageFactory->create();
    }

Затем обработчик XML-макета modulename_promo_coupons_edit.xml чтобы добавить несколько блоков для добавления формы

<body>
        <referenceContainer name="content">
            <block class="Vendor\Coupons\Block\Adminhtml\Promo\Coupons\EditContainer" name="promo_coupons_edit_container" />
            <block class="Vendor\Coupons\Block\Adminhtml\Promo\Coupons\EditContainer\EditForm" name="promo_coupons_edit_form" />
        </referenceContainer>
    </body>

Мой класс EditContainer расширяется от \Magento\Backend\Block\Widget\Form\Container и мой класс EditForm из \Magento\Backend\Block\Widget\Form\Generic

Что я делаю не так?

Это было полезно?

Решение

В вашем классе \Magento\Backend\Block\Widget\Form\Container вы ДОЛЖНЫ добавить

protected function _construct(){
        parent::_construct();

        $this->_objectId = 'simple_form';
        $this->_blockGroup = 'Examples_SimpleForm';
        $this->_controller = 'adminhtml_template';

        $this->buttonList->add('save_simple_form', ['label' => __('Save simple form')]);
    }

Примите к сведению $this->_controller = 'adminhtml_template'; который указывает, где эта форма\ контейнер должны искать классы Form/Generic (это то, что я получил)

Лицензировано под: CC-BY-SA с атрибуция
Не связан с magento.stackexchange
scroll top