# Updating data on a blog

I want to make post editing on my blog. I get data from a form and want to put it into a database. I'm not sure if using setters is the best way, so maybe you can show me better solution?

$form->handleRequest($request);

if ($form->isSubmitted() &&$form->isValid()) {
$formData =$form->getData();

$post->setTitle($formData->getTitle());
$post->setText($formData->getText());
$post->setAuthor($formData->getAuthor());
$em->flush();$this->addFlash(
'notice',
'Post updated!'
);

return $this->redirectToRoute('admin'); }  ## 1 Answer You need to add persist() like so: ...$post->setAuthor($formData->getAuthor());$em->persist($post);$em->flush();
...


That should do it!