I read several solutions for this error but it's not working, i dont know exactly where is the problem, because other get request works my formType is as follows:
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('image', null, array('property_path' => 'file'))
->add('tags', null, array('mapped' => false))
->add('machinetags', null, array('mapped' => false));
}
and function of controller is as follows:
/**
* @ApiDoc(description="Associate photo with tags.")
*
* @ParamConverter("photo", class="TestTaskPhotosBundle:Photo")
*
* @Rest\Post("/photos/{id}/tags")
* @Rest\RequestParam(name="tags", requirements=".+", nullable=false, map=true, description="Tags that associates photo.")
* @Rest\View()
*/
public function postTagsToPhotoAction(Photo $photo, array $tags)
{
$em = $this->getDoctrine()->getManager();
//TODO: add validation and maybe form
if ($tags) {
$tags = $em->getRepository('TestTaskTagsBundle:Tag')->findOrCreateByTitles($tags);
}
foreach ($tags as $tag) {
$photo->addTag($tag);
}
$em->persist($photo);
$em->flush();
return array('photo' => $photo);
}