Gibt es eine Möglichkeit, Fehler wie „Ungültiger Blocktyp“ zu beheben:Magento\Backend\Block\Empty\Edit\Form?
-
29-09-2020 - |
Frage
Es gibt eine Möglichkeit, Fehler wie „Ungültiger Blocktyp“ einfacher zu debuggen:Magento\Backend\Block\Empty\Edit\Form?
Ich versuche zu So'ne Art Klonen Sie die Funktionalität des Moduls „module-sales-rule“ zum Üben, aber ich erhalte diese Fehlermeldung, wenn ich auf mein benutzerdefiniertes Formular zugreife.
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))
Ich habe einen Controller NewAction.php mit seiner Ausführungsmethode
public function execute()
{
$this->_forward('edit');
}
Und dann mein Controller Edit.php
public function execute()
{
return $this->pageFactory->create();
}
Anschließend verarbeitet das XML-Layout modulename_promo_coupons_edit.xml, um einige Blöcke zum Hinzufügen eines Formulars hinzuzufügen
<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>
Meine EditContainer-Klasse erstreckt sich von \Magento\Backend\Block\Widget\Form\Container
und meine EditForm-Klasse von \Magento\Backend\Block\Widget\Form\Generic
Was mache ich falsch?
Lösung
In Ihrer \Magento\Backend\Block\Widget\Form\Container-Klasse MÜSSEN Sie hinzufügen
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')]);
}
Beachten Sie $this->_controller = 'adminhtml_template';
was angibt, wo dieser Form\Container nach Form/Generic-Klassen suchen soll (das habe ich bekommen)