I want to edit existing image but I could not update .Please can anyone help me.
I have used my form type in this way
$builder->add('picture', FileType::class,['label'=> 'Picture', 'required'=> false, 'data_class'=> null]);
$builder->add('submit',SubmitType::class, ['label' => 'Submit', 'attr' => ['class'=>'contact100-form-btn']]);
I have following entity
/**
* @var string
*
* @ORM\Column(name="picture", type="string", length=255, nullable=true)
*
*/
private $picture;
I have used my form handling in this way
$form = $this->createForm(userType::class, $userEntity, ['action'=>$actionUrl]);
$form->handleRequest($request);
if ($form->isSubmitted()) {
dump($form->getData());die;}
Now when I am using this form in twig {{ form_widget(form.picture) }}
the value is missing in input field <input type= "file" name= "picture">
I am not getting value of existing image on upload button.
controller for edit action
public function editUserData(Request $request, $id) {
$userEntity = $this->get('app.manage.user_data')->getUserById($id);
$actionUrl = $this->generateUrl('edit_user_data', ['id' => $id]);
$form = $this->createForm(userType::class, $userEntity, ['action' => $actionUrl]);
$form->handleRequest($request);
if ($form->isSubmitted()) {
dump($form->getData());die;
$this->addOrEditUserData($userEntity, $form, $id);
$this->addFlash("success", "Your have successfully changes data of id=" . $id);
return $this->redirect($this->generateUrl('display_user_data'));
}
return $this->render('@LillyDoo/Narayan/_edit.userData.html.twig', [
'form' => $form->createView()
]);
}
Please can any help me how I can update existing image.
Thanks