I created a new module and a new top level menu item in the Admin section. I also created a few views in the templates/[mymodule] folder, with forms I want to use in my app. The purpose of the module is to contain all the custom functionality for my client's store, firstly a small form to edit product recurring-delivery subscriptions on-the-fly.
I successfully created a non-EAV data model from a multi-table join, and populated the default view (called in index/index and loaded through the menu item) with the records. Next step, to install the "search by email address" form.
My form consists of
<form id="search_form" name="search_form" method="post" action="<?php echo $this->getUrl('editsubs/index/post') ?>">
Search by Email: < input type="text" name="emailsearch" id="emailsearch" />< /form> < button onclick="searchForm.submit()" class="scalable save" type="button">
<script type="text/javascript">
var searchForm = new varienForm('search_form');
</script>
and I have verified the URL is properly formed and it is trying to post; however the URL editsubs/index/post
is not found and Magento redirects to the dashboard.
Could missing items in config.xml cause this behavior or is there some other reason this might be occuring? Something I'm overlooking?
Magento version CE 1.4.1.1. I'm purposely keeping this very bare-bones and NOT building it on top of SaRP or using their forms.
Routers section of config is:
<admin>
<routers>
<Editsubscr2>
<use>admin</use>
<args>
<module>Kindbars_Editsubscr2< /module>
<frontName>editsubs</ frontName>
</args>
</Editsubscr2>
</routers>
</admin>
Thanks in advance!!
Kris
Don't forget the hidden formkey value.
Although this is a newbie suggestion and you probably would have noticed it before now, check that your Kindbars_Editsubscr2_IndexController
class is extendingMage_Adminhtml_Controller_Action
and has a postAction
method. And as WebFlakeStudio suggests, it wouldn't hurt to clean up the XML.
When the admin section redirects back to the dashboard, it is often because there was an exception or an error while loading the page.
Try enabling logging and checking your logs to see if you had an exception. If that doesn't work, Alan Storm has a plugin to view routes that you may want to try.
As a slightly murkier possible cause, do you have safe URLs turned on right now? If your admin URLs have long alphanumeric tokens specified, you do. Your form may need to specify a token in order for Magento to allow access to that URL.
Hope that helps!
Thanks, Joe
UPDATE:
For the "secret key", it looks like URLs should be run through Mage_Adminhtml_Model_Url::getUrl
. This function contains a method getSecretKey
that seems to append a key based on whether the keys are enabled. Also take a look at Mage_Core_Model_Session::getFormKey
, which is referenced by adminhtml/url. This should give you more insight into how those URLs are generated.
精彩评论