mam problem z zapisaniem wartości wybranej z listy wyboru <select></select> - parentId. Pojawia się komunikat:
[2/2] DBALException: An exception occurred while executing 'INSERT INTO menu (sort, parentId, enabled, label, link) VALUES (?, ?, ?, ?, ?)' with params [6, {}, 0, "fhgfgffh", "fghfghfhfh"]:
Catchable Fatal Error: Object of class BackendBundle\Entity\Menu could not be converted to string
Czepia się o parentId :/
Prosze o pomoc.
w Entity: Menu.php mam:
/** * @ORM\Column(type="integer") */ private $parentId; public function getParentId() { return $this->parentId; } public function setParentId($parentId) { $this->parentId = $parentId; }
MenuType.php:
(Lista select pobierana jest z bazy)
{ $builder // ... 'class' => 'BackendBundle\Entity\Menu', 'query_builder' => function(EntityRepository $er) { return $er->createQueryBuilder('q')->orderBy('q.sort', 'ASC'); }, 'property' => 'label', 'required' => false )) // ... ; }
MenuController:
/** * @Route("/", name="admin_menu_create") * @Method("POST") * @Template("BackendBundle:Menu:new.html.twig") */ public function createAction(Request $request) { $entity = new Menu(); $form = $this->createCreateForm($entity); $form->handleRequest($request); if ($form->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($entity); $em->flush(); } 'entity' => $entity, 'form' => $form->createView(), ); }