2

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

2
  • 1
    I'm not sure, but maybe problem is in wrong xml closing nodes? < /module> and </ frontName> have extra space character after slash Commented Nov 18, 2010 at 11:45
  • I added the spaces in the XML in order for it to appear in the post -- the actual XML is syntactically correct and well-formed. The valid XML did not appear when I typed.. Commented Nov 18, 2010 at 14:42

3 Answers 3

3

Don't forget the hidden formkey value.

Sign up to request clarification or add additional context in comments.

1 Comment

Used <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" /> in adminhtml template and this works great!
1

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.

1 Comment

Yes, all that is there and the XML was malformed in the post due to my adding spaces to get it to appear in the post. I was not aware of this board's fancy features. :)
0

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.

4 Comments

Yes, there is a long key/token value in each URL...but by calling the URL internally inside magento, I thought the system generated that key. If additional steps are needed to configure the URLs, would love to know.
I will check the logs for sure and research how to add the token..thanks!
Not a problem. Remember to hit the checkmark next to the correct answer when you post a question, to mark it as correct for people in the future.
<?php echo Mage::helper("adminhtml")->getUrl("/index/post/",array("email"=>"[email protected]")); ?> -- generates a post of the email address [email protected]

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.