Here's a problem I've got to face a lot and I think that many people are having the same problem:
I try to call an action in controller and then to redirect to the URL I came from. Let me show you the code:
I've got a basic form whose parameters are like that:
<form id="messageCreationForm" action="{{ path('createMessage') }}" method="POST">
Submitting call the following method:
/**
* @Route("/createMessage", name="createMessage")
* Request $request
*/
final public function createMessageAction(Request $request)
{
//Some logic...
return $this->generateUrl(
'/agent/campagne',
[
'agent' => $agent,
'entretiens' => $talentMatchJobs
]
);
}
Then, i got this error:
Unable to generate a URL for the named route "/agent/campagne" as such route does not exist.
However, the route exists:
enter image description here (I'm not allowed to submit image here so, click on the link to see it..)
I've also tried routes :
/campagne, campagneIndex, campagne...
The corresponding method that defines the route is this one (this route give me the url /agent/campagne:
/**
* @Route("/campagne", name="campagneIndex")
* @return Response
*/
final public function campagneIndexAction()
{
//Some logic...
}
I would really appreciate some help.. Thank you Regards,
Maxime