I am using the FPNTagBundle and I would like to have a text field to add tags to entities that works in the same way as the one on this site.
I can create a new entity with tags no problem by using explode but when I come to edit the entity again, I get something like this in the text field.
Doctrine\Common\Collections\ArrayCollection@0000000062a07bb50000000047044868
Is there a way I can pre populate a text field with the array collection, so that all of the tags appear, separated by a space?
Here's what I currently have in my controller:
public function editpageAction(Request $request, $id = NULL)
{
$em = $this->getDoctrine()->getEntityManager();
$tagManager = $this->get('fpn_tag.tag_manager');
$page = new Page();
if ( ! empty($id))
{
$page = $em->getRepository('ContentBundle:Page')->findOneById($id);
$tagManager->loadTagging($page);
}
$form = $this->createForm(new PageType(), $page);
if ($request->isMethod('POST'))
{
$form->bind($request);
if ($form->isValid())
{
$em = $this->getDoctrine()->getManager();
$em->persist($page);
$em->flush();
return $this->redirect($this->generateUrl('content_admin_list_sections'));
}
}
return $this->render('ContentBundle:Admin:page.html.twig', array('form' => $form->createView()));
}
Any advice appreciated.
Thanks