Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/279.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 未渲染Magento窗体块_Php_Magento - Fatal编程技术网

Php 未渲染Magento窗体块

Php 未渲染Magento窗体块,php,magento,Php,Magento,我正在尝试根据magento模型制作一个真正的网格。 读取部分一切正常,但要编辑的表单没有呈现,日志中也没有错误。 我注意到我的_prepareForm函数从未被调用,但我不知道为什么 我的表单呼叫控制器: public function editAction() { $this->_initAction(); // Get id if available $id = $this->getRequest()->getParam('contact_re

我正在尝试根据magento模型制作一个真正的网格。 读取部分一切正常,但要编辑的表单没有呈现,日志中也没有错误。 我注意到我的_prepareForm函数从未被调用,但我不知道为什么

我的表单呼叫控制器:

public function editAction()
{
    $this->_initAction();

    // Get id if available
    $id  = $this->getRequest()->getParam('contact_request_id');
    $model = Mage::getModel('whatever_booking/contactRequest');

    if ($id) {
        // Load record
        $model->load($id);

        // Check if record is loaded
        if (!$model->getId()) {
            Mage::getSingleton('adminhtml/session')->addError($this->__('This Contact Request no longer exists.'));
            $this->_redirect('*/*/');

            return;
        }
    }

    $this->_title($model->getId() ? $model->getName() : $this->__('New Contact Request'));

    $data = Mage::getSingleton('adminhtml/session')->getContactRequestData(true);
    if (!empty($data)) {
        $model->setData($data);
    }

    Mage::register('whatever_booking', $model);

    $this->_addBreadcrumb($id ? $this->__('Edit Contact Request') : $this->__('New Contact Request'), $id ? $this->__('Edit Contact Request') : $this->__('New Contact Request'));
    $block = $this->getLayout()->createBlock('whatever_booking/adminhtml_contactRequest_edit')->setData('action', $this->getUrl('*/*/save'));
    $this->getLayout()->getBlock('content')->append($block);

    $this->renderLayout();
} 

protected function _initAction()
{
    $this->loadLayout()
        ->_setActiveMenu('customer/ContactRequest')
        ->_title($this->__('Whatever Booking'))->_title($this->__('Contact Request'));

    return $this;
}
我的表格:

class Whatever_Booking_Block_Adminhtml_ContactRequest_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
{
    /**
     * Init class
     */
    public function _construct()
    {
        parent::_construct();
        $this->setId('whatever_booking_contactRequest_form');
        $this->setTitle($this->__('Contact Request Information'));
        //when i var dump here i see that my controller called this function
    }

    protected function _prepareForm()
    {
        var_dump('here');
        die; // this var dump is never reached
    }
}
编辑块

class Whatever_Booking_Block_Adminhtml_ContactRequest_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
{
    /**
     * Init class
     */
    public function _construct()
    {
        $this->_blockGroup = 'whatever_booking';
        $this->_controller = 'adminhtml_contactRequest';

        parent::_construct();

        $this->_updateButton('save', 'label', $this->__('Save Request'));
        $this->_updateButton('delete', 'label', $this->__('Delete Request'));
    }

    /**
     * Get Header text
     *
     * @return string
     */
    public function getHeaderText()
    {
        if (Mage::registry('contact_request')->getId()) {
            return $this->__('Edit Request');
        }
        else {
            return $this->__('New Request');
        }
    }

    protected function _prepareLayout()
    {
        // mage log is passing here when i display one
        return parent::_prepareLayout();
    }

在控制器操作中,您添加的是编辑块,而不是表单块:

<?php
// ...
    $block = $this->getLayout()->createBlock('whatever_booking/adminhtml_contactRequest_edit')->setData('action', $this->getUrl('*/*/save'));
// ...
另外,我想知道camel cased
ContactRequest
部分是否正在抛出Magento循环。试着在你的block
Contactrequest
中加入这一部分,看看是否有效(你必须重命名它的文件夹等)。

快速修复: 在您的控制器中,直接加载表单,但是最好在之前经过容器,您仍然可以这样调用它:

  $this->loadLayout(array('default', 'adminhtml_contactRequest_edit_form'))
       ->_setActiveMenu('customer/ContactRequest');
然后在用于布局的预订xml文件中:

<layout>
    <adminhtml_contactRequest_edit_form>
        <reference name="content">
            <block type="whatever_booking/adminhtml_contactRequest_edit_form" name="aeschbachbooking.form" />
        </reference>
    </adminhtml_contactRequest_edit_form>
</layout>


您的控制器似乎错过了对$this->loadlayout()的调用,是在_initaction()中吗?我用我的_initaction编辑了帖子,是的,它在那里被调用了,所以这不是问题:)嗨,我的无论什么预订_Block(Block)(Block)Adminhtml(ContactRequest)(Edit)正在扩展Mage(Adminhtml)Block。我试图重写_prepareLayout,只是想看看它是否被调用,是的,我的代码正在遍历这个函数(只是调用它的父函数)在任何形式的camel案例中,我猜它通过得很好,因为我是从一个网格及其网格容器中获得的,该网格和它的网格容器具有相同的结构,无论是什么形式的BOCKING、Block、Adminhtml、ContactRequest,还是什么形式的BOCKING、Block、Adminhtml、ContactRequest、grid,因此,我认为这也不是问题,Magento也没有在这一领域带来驼峰案例的问题,只是使用下划线并不好:)这似乎可行,但正如你所说的,通过容器可能会更好。我将等待,看看是否有人使它与容器的工作。谢谢,所以如果我直接到达表单,我没有容器的按钮
<layout>
    <adminhtml_contactRequest_edit_form>
        <reference name="content">
            <block type="whatever_booking/adminhtml_contactRequest_edit_form" name="aeschbachbooking.form" />
        </reference>
    </adminhtml_contactRequest_edit_form>
</layout>