Reputation: 398
What i want is to change the action for "add new" button
class World_Exporter_Block_Adminhtml_Attribute extends Mage_Adminhtml_Block_Widget_Grid_Container{
public function __construct()
{
$location = str_replace('new', 'newMap', $this->getCreateUrl());
$this->_controller = 'adminhtml_attribute';
$this->_blockGroup = 'exporter';
$this->_headerText = Mage::helper('exporter')->__('Attribute Manager ');
$this->_addButtonLabel = Mage::helper('exporter')->__('Add Item');
parent::__construct();
$this->setCreateUrl($location);
$this->_addButton('add', array(
'label' => $this->getAddButtonLabel() ,
'onclick' => 'setLocation(\'' . $location .'\')',
'class' => 'add',
));
// echo $this->getCreateUrl();
}
}
after trying so much i am still being able to change "newAction" to any other.. Plz help
Upvotes: 2
Views: 4822
Reputation: 613
Yevgeny's answer is good but I would change some little things in his code :
public function __construct()
{
$this->_controller = 'adminhtml_collection';
$this->_blockGroup = 'story';
$this->_headerText = Mage::helper('customer')->__('Manager');
//Replace the first argument "add" by something else,
//or both your new button and the original add button
//won't be visible.
$this->_addButton('btnAdd', array(
'label' => Mage::helper('story')->__('Add Item'),
'onclick' => "setLocation('" . $this->getUrl('*/*/new', array('page_key' => 'collection')) . "')",
'class' => 'add'
));
//Moved parent's constructor here (not necessary I think)
parent::__construct();
//Remove original add button
$this->_removeButton('add');
}
This line removes the original add button, leaving only your new button containing the new action :
$this->_removeButton('add');
Note : Be sure to remove the original button after the call to :
parent::__construct();
or the original button will stay in the Grid.
Upvotes: 7
Reputation: 11
public function __construct()
{
$this->_controller = 'adminhtml_collection';
$this->_blockGroup = 'story';
$this->_headerText = Mage::helper('customer')->__('Manager');
parent::__construct();
$this->_addButton('add', array(
'label' => Mage::helper('story')->__('Add Item'),
'onclick' => "setLocation('" . $this->getUrl('*/*/new', array('page_key' => 'collection')) . "')",
'class' => 'add'
));
}
Upvotes: 1