2 thoughts on “Validating multiple files in Symfony 2.5

  1. Best solution:

    $documents = new Documents();
    $form = $this
    ->createFormBuilder($documents)
    ->add(‘documents’, ‘file’, [
    ‘required’ => false,
    ‘multiple’ => true
    ])
    ->getForm()
    ->handleRequest($request);

    class Documents
    {
    /**
    * @Assert\Count(max = “3”)
    * @Assert\All({
    * @Assert\NotNull()
    * })
    *
    * @var UploadedFile[]
    */
    protected $files;

    // set and get methods for $files
    }

Leave a Reply

Your email address will not be published. Required fields are marked *