0

I have the following, (Note the capital and non capital letters.)

In app/design/adminhtml/default/default/template/customertab/action.phtml

  <form action="&lt;?php echo $this-&gt;getUrl('adminhtml/customertab/reset/'); ?&gt;" method="get"><input type="submit" value="Post This Form" /></form>

app/code/local/Sean/CustomerTab/controllers/Adminhtml/CustomerTabController.php

<?php

class Sean_CustomerTab_Adminhtml_CustomerTabController extends Mage_Adminhtml_Controller_Action
{
    function resetAction()
    {
        die("I'm lame");
    }

}

inside app/code/local/Sean/CustomerTab/etc/config.xml I have:

<config>
    <modules>
        <Sean_CustomerTab>
            <version>0.0.1</version>
        </Sean_CustomerTab>
    </modules>
    <adminhtml>
        <layout>
            <updates>
                <customertab>
                    <file>customertab.xml</file>
                </customertab>
            </updates>
        </layout>
    </adminhtml>
    <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <sean_customertab before="Mage_Adminhtml">Sean_CustomerTab_Adminhtml</sean_customertab>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>
    <global>
        <blocks>
            <customertab>
                <class>Sean_CustomerTab_Block</class>
            </customertab>
        </blocks>
    </global>
</config>

Why when I submit this form does it not call the function resetAction in my controller and die?

I know we are suppose to do 'module/controller/action' in the getUrl

CodingMageSheen
  • 532
  • 5
  • 16

2 Answers2

1

You have to add formkey in your form

<input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />

so your form look like below:

<form action="&lt;?php echo $this-&gt;getUrl('adminhtml/customertab/reset/'); ?&gt;" method="get">
   <input type="submit" value="Post This Form" />
   <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
</form>
Prashant Valanda
  • 12,659
  • 5
  • 42
  • 69
0

The thing missing was if you look into the controller there is:

class Sean_CustomerTab_Adminhtml_CustomerTabController

Since the T in Tab of CustomerTabController is capitalized, when I reference it in getUrl('adminhtml/customertab/reset/')

it had to be 'adminhtml/customerTab/reset/' and it works

CodingMageSheen
  • 532
  • 5
  • 16