Posted By

interviewqueries on 09/14/19


Tagged

symfony VichUploaderBundle


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

interviewqueries


How to render the input with VichUploaderBundle IN Symfony?


 / Published in: Symfony
 

URL: https://www.interviewqueries.com/symfony-interview-questions/

I've a trouble with the bundle VichUploaderBundle with Symfony 4. I've follow a tutorial to make an upload with VichUploaderBundle to upload multiple files.

My problem is that the input form to upload the file is never render. But I don't see what it's wrong with my Type file.

In my MemberType who can find all fiels, I've

... ->add('memberfiles', CollectionType::class, [ 'label' => 'Add a file', 'entrytype' => MemberFilesType::class, 'allowadd' => true, 'allowdelete' => true, 'prototype' => true ]) ...

  1. <?php
  2.  
  3. namespace App\Form;
  4.  
  5. use App\Entity\MemberFiles;
  6. use Symfony\Component\Form\AbstractType;
  7. use Symfony\Component\Form\FormBuilderInterface;
  8. use Symfony\Component\OptionsResolver\OptionsResolver;
  9. use Vich\UploaderBundle\Form\Type\VichImageType;
  10.  
  11.  
  12. class MemberFilesType extends AbstractType
  13. {
  14. public function buildForm(FormBuilderInterface $builder, array $options)
  15. {
  16. $builder
  17. ->add('imageFile', VichImageType::class, [
  18. 'required' => false,
  19. 'download_uri' => true,
  20. 'image_uri' => true
  21. ])
  22. ;
  23. }
  24.  
  25. public function configureOptions(OptionsResolver $resolver)
  26. {
  27. $resolver->setDefaults([
  28. 'data_class' => MemberFiles::class,
  29. ]);
  30. }
  31. }

Report this snippet  

You need to login to post a comment.