7

In custom module I have one grid. in that grid i don't want to edit data from admin panel. I want to just view of that data so i want to remove save button and reset button.

In Edit.php

public function __construct()
{
    parent::__construct();
    $this->_objectId = "example_id";
    $this->_blockGroup = "example";
    $this->_controller = "adminhtml_example";
    // $this->_updateButton("save", "label", Mage::helper("example")->__("Save Tutor"));
    $this->_updateButton("delete", "label", Mage::helper("example")->__("Delete Tutor"));

    /**
    $this->_addButton("saveandcontinue", array(
        "label"     => Mage::helper("example")->__("Save And Continue Edit"),
        "onclick"   => "saveAndContinueEdit()",
        "class"     => "save",
    ), -100);

    $this->_formScripts[] = "
        function saveAndContinueEdit() {
            editForm.submit($('edit_form').action+'back/edit/');
        }
    ";
    */
}   

I m comment code of save button and saveAndContinueEdit button but save button is display.

I know another way to admin can't save data using disable set as true in all addfield but i want to remove add button and reset button if possible and i want to remove this button using custom module.

13

Add this in the method you mentioned

$this->_removeButton('save');
$this->_removeButton('delete');
$this->_removeButton('reset');
| improve this answer | |
4

Note that Magento does not want you to override the __construct method. You should override the _construct method instead. One problem is that you cannot remove buttons in the _construct method. But you can simply override the _prepareLayout method for that purpose:

protected function _prepareLayout()
{
    $this->_removeButton('save');
    $this->_removeButton('delete');
    $this->_removeButton('reset');

    return parent::_prepareLayout();
}
| improve this answer | |
  • 1
    That's true, but there are a lot of core classes that override the __construct method. – Marius May 22 '15 at 8:35
  • 1
    @Marius Core classes are often not good as a reference for good code style I think :D – Simon May 22 '15 at 9:38
3

To remove buttons on MAGENTO 2 admin form:

$this->buttonList->remove('delete');
$this->buttonList->remove('save');
$this->buttonList->remove('reset');
$this->buttonList->remove('back');
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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