0

My problem should be pretty simple, yet I haven't found a solution. In Symfony 2.3, I validate forms using the built in validator. This works as expected. I would like to show the user the max. size for uploading a file but I don't want to hardcode it in the template but read it out of the validation.yml.

For reading values out of the parameters.yml file, I can use

$this->container->getParameter('xyz')

Is there something similar to read the validation.yml?

Emanuel Oster
  • 1,296
  • 10
  • 21

1 Answers1

0

You may add a validation for the file in validations.yml and specify the maximum size there.

TSZ\CoreBundle\Entity\ContentImage:
  properties:
        file:
            - File:
                maxSize: 6000000

To specify the size in bytes, use the numerical value corresponding to the maximum size. To specify the size in kilobytes, suffix "k" to the numerical value (1024K). To specify the size in megabytes, suffix "M" to the numerical value(1M).

Praveesh
  • 1,257
  • 1
  • 10
  • 23