We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Form in Custom Module always Submits to the CP Homepage

Development and Programming

Milsoft's avatar
Milsoft
27 posts
15 years ago
Milsoft's avatar Milsoft

I’m working on converting an EE1 module to EE2. I’ve looked through the development guides on the website upgrading a module from EE1 to EE2, and I’ve got most things worked out, but I’m having an issue.

My mymodule_mcp->index() method displays a form that holds some configuration data for my module. Whenever you submit the form, it suppose to simply update the database and redirect back to mymodule_mcp->index() method.

I’m using the following to set my form action in my view:

$vars['form_submit_url'] = BASE.AMP."C=addons_modules".AMP."M=show_module_cp".AMP."module=mymodule".AMP."method=update_config";

When I submit the form, it takes me back to the control panel homepage, but if I copy the action from the form and paste it into the browser and hit enter, it runs the proper mymethod_mcp->update_config() method just fine.

Any ideas why my form submission doesn’t hit the correct method and redirects to the control panel homepage?

Thanks!

       
Greg Aker's avatar
Greg Aker
6,022 posts
15 years ago
Greg Aker's avatar Greg Aker

Are you using CI’s form_open() for your form tag, or an HTML form tag? What’s the rendered link when you view source?

       
Parse19's avatar
Parse19
44 posts
15 years ago
Parse19's avatar Parse19

Just wanted to piggy back on this for anyone looking for an answer to this problem in the forums.

EE has a form_helper extension that checks to see whether the request is a control panel request and then adds on the BASE.AMP to the action when using the form_open function.

That means if you happen to set a variable (like I do) for convenience that has your BASE.AMP.’C=’… etc then using it with form_open will result in the submitting to the CP home page. The form_open function will not mess with a full URL, but it can be hard to determine the CP URL correctly if you want the add-on to work on a lot of setups.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.