Код: Выделить всё
public function indexAction(Request $request, $id)
{
if($id != null)
{
// Create a new Review entity
$review = new Review();
$form = $this->createForm(ReviewType::class, $review,[
'action' => $request->getUri()
]);
$form->handleRequest($request);
if($form->isValid()) {
$manager = $this->getDoctrine()->getManager();
$review->setPosted(new \DateTime());
$review->setBookID($id);
$review->setUserID($this->getUser());
$manager->persist($review);
$manager->flush();
}
return $this->render('ReviewBookBundle:Book:index.html.twig',
['form' => $form->createView());
}
}
Код: Выделить всё
Expected value of type "Review\BookBundle\Entity\Book" for association field "Review\ReviewsBundle\Entity\Review#$bookID", got "string" instead.
Код: Выделить всё
$review->setBookID($book);
Подробнее здесь: https://stackoverflow.com/questions/413 ... ng-instead