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

1
  • show your config.xml file. Without that, it is difficult to help you out further. Nov 22, 2016 at 4:10

2 Answers 2

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>
4
  • I'll try this tomorrow morning and upvote if it works! ty for responding :D it has to have name="form_key" ? and is there any reason for that? my other controllers didn't use that, is it because it's in the admin panel Nov 22, 2016 at 5:48
  • Please refer magento.stackexchange.com/questions/43962/… Nov 22, 2016 at 5:54
  • This didn't work :( Nov 22, 2016 at 19:37
  • @CodingMageSheen formkey is required for form submit but if it didn't work then any other issue are you facing Nov 23, 2016 at 4:39
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

Your Answer

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

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