$builder
->add('title')
->add('content')
->add('author', EntityType::class, [
'class' => User::class
])
;
$post = $form->getData();
$em->persist($post);
$em->flush();
/**
* @return User|null
*/
public function getAuthor(): ?User
{
return $this->author;
}
/**
* @param User $author
*
* @return Post
*/
public function setAuthor(User $author): Post
{
$this->author = $author;
return $this;
}