Okay, so this is the first time i’ve written a module so probably a newb question here!
I’m slowly building up a module and one of the things it needs to be able to do is save settings.
So in my mcp file i have an ‘index’ method and a ‘save_settings’ method.
function save_settings()
{
error_log('save settings function');
$this->EE->session->set_flashdata('message_success', $this->EE->lang->line('record_added'));
$this->EE->functions->redirect(BASE.AMP.'C=addons_modules'.AMP.'M=show_module_cp'.AMP.'module=refer_a_friend');
}Right now, the save settings method doesn’t really do anything, it just flashes a success message and redirects to the module index page.
The thing is, it only words when I access it directly by typing in the method name in the browser address bar.
When I submit the form on the index page which calls it, I wind up at the control panel home page. When I take the form action attribute and paste it directly into the address bar, I get the desired action, so I know it’s not a problem with my form action attribute.
I have an error log in there, and I can see that it isn’t being processed at all when I submit my form.
I have looked at the apache log but no clue there… this is what happens:
127.0.0.1 - - [09/Sep/2011:15:34:25 -0700] "POST /system/index.php?S=fa1a9ef3d8437ec0d33da8e0012b2d37467291bb&D=cp&C=addons_modules&M=show_module_cp&module=refer_a_friend&method=save_settings HTTP/1.1" 302 20
127.0.0.1 - - [09/Sep/2011:15:34:25 -0700] "GET /system/index.php?S=fa1a9ef3d8437ec0d33da8e0012b2d37467291bb&D=cp HTTP/1.1" 302 20But if I enter the URL (get) it goes where I expect it to
127.0.0.1 - - [09/Sep/2011:15:34:49 -0700] "GET /system/index.php?S=fa1a9ef3d8437ec0d33da8e0012b2d37467291bb&D=cp&C=addons_modules&M=show_module_cp&module=refer_a_friend&method=save_settings HTTP/1.1" 302 20
127.0.0.1 - - [09/Sep/2011:15:34:50 -0700] "GET /system/index.php?S=fa1a9ef3d8437ec0d33da8e0012b2d37467291bb&D=cp&C=addons_modules&M=show_module_cp&module=refer_a_friend HTTP/1.1" 200 13664I’ve spent a couple of hours trying things here, including looking at other 3rd party modules, so any pointers greatly appreciated.
Hi,
I just encountered this issue too.
It seems that something is missing in the code which is being outputted by Package Builder for ExpressionEngine.
It seems that it is possible to avoid unneeded redirect to CP homepage by adopting approach used in Bitly module.
Still, it would be interesting to find what causes that redirect.
I will return to coding and investigation of this issue Monday.
If you will find some clue, please, post your findings here.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.