I have some actions defined like “action = ‘[module]/[action]'” & submit.
The result is ‘[currentUrl]/[module]/[action]’ instead of ‘[module]/[action]’, I can’t figure out why, here’s the code :
On the front :
<a href="<?php echo ( isset($disabledMajSuivi) && $disabledMajSuivi ? "#" : "javascript:showYesNoDialog('". addslashes(__('enquete.visu.msg.confirmation.majsuivi')). "', 'majSuivi')" ); ?>" >
<?php echo __('enquete.visu.majsuivi');?>
</a>
showYesNoDialog is a javascript function where first arg is the sentence displayed and second arg is callback function, so ‘majSuivi’ is called back and looks like this :
<script>
function majSuivi(response) {
if(response == 'yes') {
document.forms[0].action = "module_name/majsuivi";
document.forms[0].submit();
}
}
This has been debugged, the condition is true.
The action ‘majSuivi’ (that is big) ends like this :
$this->redirect('enquete/visu?enq_id='.$enq_id
. (!is_null($personneMorale) ? '&pm_id='.$personneMorale->getPmId() : '') );
But no action is executed because of the wrong url (so actualy this part of code is kind of useless).
So when the URL should be : http://[baseUrl]/index.php/module_name/majsuivi
It is instead : http://[baseUrl]/index.php/enquete/visu/enq_id/24/menu_id/module_name/majsuivi
Where /index.php/enquete/visu/enq_id/24/menu_id/ was the current url just before calling ‘majSuivi action.
Each time I click on the “a href” button, it adds the “module_name” to the URL like following :
click -> http://[baseUrl]/index.php/enquete/visu/enq_id/24/menu_id/module_name/majsuivi
click2 -> http://[baseUrl]/index.php/enquete/visu/enq_id/24/menu_id/module_name/module_name/majsuivi
click3 -> http://[baseUrl]/index.php/enquete/visu/enq_id/24/menu_id/module_name/module_name/module_name/majsuivi
etc …
I don’t think it comes from the routing.yml config file, but if someone thinks it could, I’ll write the content of it.
Thanks for your help
You should use something like this:
or
or if you have this route in your routing.yml
Because
'module_name/majsuivi'is a relative path and will be concatenated with your current url without/at the beginning