I have a user table. In that table I have different fields. I only need to update the image column of the user table.
I have a form for uploading the image only. Even though the image is set but when I submit the form I get validations errors of other fields.
I know that the validation errors are because I passed the user object to the form and issued a isValid().
How do I only update the specific column like the image column?
public function updateImageAction(Request $request){
$form = $this->createForm(new UploadImageType(),new User(),[
'action' => $this->generateUrl('update_image')
]);
$form->handleRequest($request);
$user = $this->getUser();
if ($form->isSubmitted() && $form->isValid())
{
$em = $this->getDoctrine()->getManager();
$data = $form->getData();
dump($data);die;
$em->persist($data);
$em->flush();
}
return $this->render('photo.html.twig', [
'form' => $form->createView()
]);
}