I don't like that method of providing your own frontName
, I prefer to overload the existing admin router because it's neat and quick. Start by changing this in your config.xml:
<admin>
<routers>
<adminhtml>
<args>
<modules>
<ics_easylife before="Mage_Adminhtml">Ics_EasyLife_Adminhtml</ics_easylife>
</modules>
</args>
</adminhtml>
</routers>
</admin>
This will make magento check for controller classes that start with Ics_EasyLife_Adminhtml
before checking it's own Mage_Adminhtml
. Rename your controller to Ics_EasyLife_Adminhtml_EasylifeController
and rename it's corresponding file to EasylifeController.php
.
Now an URL of adminhtml/easylife
will expand to http://ipaddress/ics/admin/easylife/index
and call your indexAction
method. When making a menu entry use that URL of adminhtml/easylife
. Even if you don't have any layout or blocks in place yet at least a page will show. When writing a layout use the layout handle <adminhtml_easylife_index>
.
Starting of with the buttons. There is no technical difference between the buttons. It's only a styling matter. If you use the Magento button (and it's best to do so) you'll get a nicely styled button. Beyond that, both buttons do the same. The submit the form they're attached to.
How ever, make sure the type
of the button is submit
and not button
.
Second, the redirect.
The redirect should be done in the controller and not in an onclick event of the button. The flow is roughly something like this.
user fills out form and clicks button
> controller handles the post data and saves it
> controller redirects to desired end page
Your controller would look something like this
class [Namespace]_[Module]_IndexController
{
public function indexAction()
{
[...]
// page that displays your form
[...]
}
public function postoneAction()
{
[...]
// code that handles the post data
[...]
// redirect back to the index page, or any other page of your controller
$this->_redirect('*/*/index');
}
public function posttwoAction()
{
[...]
// code that handles the post data differently
[...]
// redirect back to the index page, or any other page of your controller
$this->_redirect('*/*/index');
}
}
[EDIT] to have 2 different types of 'submit', take a look at this post on Stackoverflow on swapping the action
of the form depending on the button.
Basically you remove the action
from the form, add a name to the form (myform
for example) and add it to the
onclick` of the buttons. Something like this.
<button onclick="document.myform.action='practice/index/postone';document.myform.submit();"> .... </button>
<button onclick="document.myform.action='practice/index/posttwo';document.myform.submit();"> .... </button>
Best Answer
this is something you can find around
Mage_Adminhtml_Block_Widget_Grid
class, check it's_prepareMassaction
method. This is where that button comes from.Specifically, for products grid page check out file
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Grid.php
for better understanding.This is specific part of code in that file that reflects as "Delete" item in dropdown on your screen: