I have complex problem. I'm using jquery tabs on my Prestashop module. I have following tabs on my plugin page:
Inside every tab I have inputs for my plugin and save button. If I'm on e.g Footer
and I will click my save button then page refreshes, save changes and then I'm in my first tab (General
) instead of Footer
.
I found solution for this. After every SAVE I'm using
return header("Location: ".$moduledir.'#'.$tab);
where $tab = 'tabname'
and $moduledir = plugin url
. Header location protects me before re-submitting the form after F5 page refresh. But it's also not effective because I'm also need to pass some informations after save e.g 'Configuration updated' or some error.
public function Output($tab,$outputmessage=null)
{
$moduledir = $_SERVER['PHP_SELF'].'?controller=AdminModules&token='.Tools::getAdminTokenLite('AdminModules').'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name;
if ($tab == null)
{
return $this->RenderConfig(); # This method displays my plugin
}
else
{
# I don't know how to also pass by header location my
# $outputmessage variable which contains
# information to display. Normally I would use
# return $outputmessage.$this->RenderConfig();
# but then it's always brings me to tab general
return header("Location: ".$moduledir.'#'.$tab);
}
}
I know that probably there is a better way to do this but I don't know how. Please guys, give me some tips because I'm stupid right now and have no idea how to solve this.
// EDIT
I think I found solution but for now I'm not 100% sure.
public function Output($tab,$display=null)
{
$tab = '<script>parent.location.hash = "'.$tab.'";</script>';
return $tab.$display.$this->RenderConfig();
}