T
T
TANK_IST2017-08-07 05:45:17
symfony
TANK_IST, 2017-08-07 05:45:17

How to make symfony validation not validate a field if it is null?

entity:

/**
     * @ORM\Column(type="string", nullable=true)
     * @Assert\Image(
     *     mimeTypes={ "image/jpeg", "image/png", "image/gif" },
     *     minWidth=200,
     *     minHeight=200,
     *     maxHeight=4000,
     *     maxWidth=4000,
     *     detectCorrupted=true,
     *     maxSize="8M",
     *     maxRatio=3,
     *     minRatio=0.25
     * )
     */
    protected $passport = null;

If the user has not uploaded, then he is shown an error, but this field is not required.
How to fix it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Oleg, 2017-08-07
@Austin_Powers

Try to set the attribute "required" = false in the form

A
Anatoly Medvedev, 2017-08-07
@balamyt92

@Assert\Null()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question