1

This should be so simple, but _removeButton() method is not working.

class Thing_MyModule_Block_Adminhtml_Foo 
        extends Mage_Adminhtml_Block_Widget_Grid_Container {

    public function _construct() {
        $this->_controller = 'adminhtml_mymodule';
        $this->_blockGroup = 'mymodule';
        $this->_headerText = Mage::helper('mymodule')->__('Hello There');
        parent::_construct();
        $this->_removeButton('add'); // does not work
    }

}

Needless to say I'm missing something obvious and the "+ Add New" button is still there. Yes, I have tried it before and after the call to parent::_construct();

If I do var_dump($this->_buttons); I get

array (size=3)
  -1 => 
    array (size=0)
      empty
  0 => 
    array (size=0)
      empty
  1 => 
    array (size=0)
      empty

...which makes no sense to me. AM LOSING MY MIND! Please help!

Magento ver. 1.8.1.0

1 Answer 1

1

Solved. Rather than calling _removeButton() in _construct(), calling it in _prepareLayout() works just fine.

class Thing_MyModule_Block_Adminhtml_Foo 
    extends Mage_Adminhtml_Block_Widget_Grid_Container {

    public function _construct() {
        $this->_controller = 'adminhtml_mymodule';
        $this->_blockGroup = 'mymodule';
        $this->_headerText = Mage::helper('mymodule')->__('Hello There');
        parent::_construct();
        $this->_removeButton('add');  // this does not work
    }

    protected function _prepareLayout() {
        $this->_removeButton('add');  // this is just dandy
        return parent::_prepareLayout();
    }

    ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.