Is it possible tu use the @ParamConverter annotation in Symfony2 to convert a parameter send via the $_POST request into an Entity?
All examples given in the symfony2 documentation convert entities from parameter defined in the route.
Setting something like that:
/**
* @Route("/")
* @ParamConverter("user", class="BvStandardServiceBundle:User", options={"id" = "userId"})
*/
public function userAction(User $user)
{
}
If I call this route with an id in the userId
$_POST param, it results in:
Unable to guess how to get a Doctrine instance from the request information.
The paramConverter of symfony run only for request param into the URL unfortunately : ParamConverter specification
Framework work directly with the URL param for search the association between param url and paramConverter. If you don't use a param into your URL, the engine symfony will don't search association with your paramConverter.
You can also view the kernel.event for this which need request for work : Class : ParamConverterListener.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With