Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Count constraint 'min'=>1 applied against file field type with 'multiple'=>true is ignored #12547

Closed
@nurikabe

Description

@nurikabe

For example:

    $builder = $this->get('form.factory')->createBuilder();
        $form = $builder
            ->add('documents', 'file', array(
                'required' => false,
                'multiple' => true,
                'constraints' => array(
                    new Count(array('min'=>1)),
                )
            ))
            ->add('submit', 'submit')
            ->getForm()
        ;

This validates true even if no file is selected. If min is greater than one, however, the constraint behaves as expected and the form fails with "This collection should contain # elements or more."

Experiencing this in both 2.5.7 as well as 2.6.0-BETA1.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions