Skip to content

[Form][Validator] Specify attributes of fileType thanks to validatorTypeGuesser #29327

Closed
@BorisCharriere

Description

@BorisCharriere

Description
We could use the property mimeTypes of the Symfony\Component\Validator\Constraints\File to specify the attribute accepted of the field

Example

in Symfony\Component\Form\Extension\Validator\ValidatorTypeGuesser line 125

                if ($constraint->mimeTypes){
                    return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\FileType', array('attr' => ['accept' => implode(', ', $constraint->mimeTypes)]), Guess::HIGH_CONFIDENCE);
                }
                return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\FileType', array(), Guess::HIGH_CONFIDENCE); ```

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