M
M
Maxim2015-10-01 15:59:18
symfony
Maxim, 2015-10-01 15:59:18

Why is the record in the database not updated?

I can not understand why the data in the database from the form is not updated.

$em = $this->getDoctrine()->getManager();
$vote = $em->getRepository('ACVoteVotesBundle:Votes')->findById($id);
$form = $this->createForm(new addVoteInfoType(), $vote);
$form->handleRequest($request);
$em->flush();

What's wrong?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis, 2015-10-01
@maxpointn2point

The findBy* method returns an array.
Use findOneBy* or find($id) in the current case.

S
shaqster, 2015-10-01
@shaqster

You forgot to do before flush.
$em->persist($vote);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question