保存,后退和删除按钮在magento admin中不起作用

时间:2015-06-02 08:43:46

标签: magento button adminhtml

我的Magento上安装了StoreLocator模块。编辑商店时,您应该可以按3个按钮(保存,删除,返回)。按钮不起作用,没有标签。

这是图片:

enter image description here

我检查了模块,发现它扩展了Mage_Adminhtml_Block_Widget_Form_Container。

这里是Eroi_Locator_Block_Adminhtml_Locator_Edit:

class Eroi_Locator_Block_Adminhtml_Locator_Edit extends Mage_Adminhtml_Block_Widget_Form_Container{

public function __construct()
{
    parent::__construct();

    $this->_objectId = 'id';
    $this->_blockGroup = 'locator';
    $this->_controller = 'adminhtml_locator';

    $this->setTemplate('locator/edit.phtml');

    $this->_updateButton('save', 'label', Mage::helper('locator')->__('Save Location'));
    $this->_updateButton('delete', 'label', Mage::helper('locator')->__('Delete Location'));

}

public function getHeaderText()
{
    if( Mage::registry('locator_data') && Mage::registry('locator_data')->getId() ) {
        return Mage::helper('locator')->__("Edit Location '%s'", $this->htmlEscape(Mage::registry('locator_data')->getName()));
    } else {
        return Mage::helper('locator')->__('Add Location');
    }
}

public function getId()
{
    return Mage::registry('locator_data')->getId();
}

这是Mage_Adminhtml_Block_Widget_Form_Container:

class Mage_Adminhtml_Block_Widget_Form_Container extends Mage_Adminhtml_Block_Widget_Container{

protected $_objectId = 'id';
protected $_formScripts = array();
protected $_formInitScripts = array();
protected $_mode = 'edit';
protected $_blockGroup = 'adminhtml';

public function __construct()
{
    parent::__construct();

    if (!$this->hasData('template')) {
        $this->setTemplate('widget/form/container.phtml');
    }

    $this->_addButton('back', array(
        'label'     => Mage::helper('adminhtml')->__('Back'),
        'onclick'   => 'setLocation(\'' . $this->getBackUrl() . '\')',
        'class'     => 'back',
    ), -1);
    $this->_addButton('reset', array(
        'label'     => Mage::helper('adminhtml')->__('Reset'),
        'onclick'   => 'setLocation(window.location.href)',
    ), -1);

    $objId = $this->getRequest()->getParam($this->_objectId);

    if (! empty($objId)) {
        $this->_addButton('delete', array(
            'label'     => Mage::helper('adminhtml')->__('Delete'),
            'class'     => 'delete',
            'onclick'   => 'deleteConfirm(\''. Mage::helper('adminhtml')->__('Are you sure you want to do this?')
                .'\', \'' . $this->getDeleteUrl() . '\')',
        ));
    }

    $this->_addButton('save', array(
        'label'     => Mage::helper('adminhtml')->__('Save'),
        'onclick'   => 'editForm.submit();',
        'class'     => 'save',
    ), 1);
}

protected function _prepareLayout()
{
    if ($this->_blockGroup && $this->_controller && $this->_mode) {
        $this->setChild('form', $this->getLayout()->createBlock($this->_blockGroup . '/' . $this->_controller . '_' . $this->_mode . '_form'));
    }
    return parent::_prepareLayout();
}

/**
 * Get URL for back (reset) button
 *
 * @return string
 */
public function getBackUrl()
{
    return $this->getUrl('*/*/');
}

public function getDeleteUrl()
{
    return $this->getUrl('*/*/delete', array($this->_objectId => $this->getRequest()->getParam($this->_objectId)));
}

/**
 * Get form save URL
 *
 * @deprecated
 * @see getFormActionUrl()
 * @return string
 */
public function getSaveUrl()
{
    return $this->getFormActionUrl();
}

/**
 * Get form action URL
 *
 * @return string
 */
public function getFormActionUrl()
{
    if ($this->hasFormActionUrl()) {
        return $this->getData('form_action_url');
    }
    return $this->getUrl('*/' . $this->_controller . '/save');
}

public function getFormHtml()
{
    $this->getChild('form')->setData('action', $this->getSaveUrl());
    return $this->getChildHtml('form');
}

public function getFormInitScripts()
{
    if ( !empty($this->_formInitScripts) && is_array($this->_formInitScripts) ) {
        return '<script type="text/javascript">' . implode("\n", $this->_formInitScripts) . '</script>';
    }
    return '';
}

public function getFormScripts()
{
    if ( !empty($this->_formScripts) && is_array($this->_formScripts) ) {
        return '<script type="text/javascript">' . implode("\n", $this->_formScripts) . '</script>';
    }
    return '';
}

public function getHeaderWidth()
{
    return '';
}

public function getHeaderCssClass()
{
    return 'icon-head head-' . strtr($this->_controller, '_', '-');
}

public function getHeaderHtml()
{
    return '<h3 class="' . $this->getHeaderCssClass() . '">' . $this->getHeaderText() . '</h3>';
}

/**
 * Set data object and pass it to form
 *
 * @param Varien_Object $object
 * @return Mage_Adminhtml_Block_Widget_Form_Container
 */
public function setDataObject($object)
{
    $this->getChild('form')->setDataObject($object);
    return $this->setData('data_object', $object);
}

}

0 个答案:

没有答案