How can i send parameters to validators.lang.yml in symfony2 validator engine?

R. Canser Yanbakan

I want to translate validation messages in symfony2.

address:
    - NotBlank: { message: "address.address.not_blank" }
    - Length:
        min: 10
        minMessage: "address.address.min_length"

I want to show min or max limit parameter.

address.address.min_length: Address must be at least %limit% characters length

But this isn't working!

My translation file name is validators.en.yml.

Users getting error message exactly like this. They are not able to see

%limit%

How can i show them limit parameter?

Jovan Perovic

According to the official documentation you should use token:

{{ limit }}

and not

%limit%

Now, if you want to supply some parameters that are not strictly bound for the Length validator you should probably implement your own validator with translator service as an argument. Then it would be just as easy to use it as Length inside configuration.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Symfony2: how to read parameters array in config.yml

From Dev

Symfony2: How can I send the current user to the edit form without overwritting the entity to edit?

From Dev

Symfony2: How can I send the current user to the edit form without overwritting the entity to edit?

From Dev

Symfony2, How can I pass parameters sort and direction using KnpPaginatorBundle and QueryBuilder

From Dev

I can't get SwiftMailer to send in a Symfony2 Command

From Dev

How do I send a data from Validator::extend() to Validator::replacer() so that my message can be more detailed?

From Dev

How can I access parameters defined in parameters.yml from within a twig template?

From Dev

How can I access parameters defined in parameters.yml from within a twig template?

From Dev

How do I pass a parameter to a validation constraint in Symfony2 - in yml

From Dev

How do I pass a parameter to a validation constraint in Symfony2 - in yml

From Dev

In Symfony2 how can I append a date to the assetic filenames

From Dev

How can I throw a 403 exception in Symfony2?

From Dev

How can I catch errors and exceptions in Symfony2/Silex?

From Dev

How can I get the action name in a Symfony2 controller?

From Dev

How can I dynamically set a parameter in Symfony2?

From Dev

How can I do to reload a symfony2 server with gulp?

From Dev

How can I inject doctrine into Symfony2 service

From Dev

How can i show the first published demands in Symfony2 ?

From Dev

How can I create complex reports with PHP / Symfony2?

From Dev

How can I join multiple tables in symfony2?

From Dev

How can I load templates from subdirectories in Symfony2?

From Dev

How can I get the action name in a Symfony2 controller?

From Dev

How can I dynamically set a parameter in Symfony2?

From Dev

How can I create complex reports with PHP / Symfony2?

From Dev

how can I change the implementation of FlashBag messages in Symfony2

From Dev

In Symfony2 how can I append a date to the assetic filenames

From Dev

How can i restrict acces in my page? Symfony2

From Dev

How can I join multiple tables in symfony2?

From Dev

How can I do to reload a symfony2 server with gulp?

Related Related

  1. 1

    Symfony2: how to read parameters array in config.yml

  2. 2

    Symfony2: How can I send the current user to the edit form without overwritting the entity to edit?

  3. 3

    Symfony2: How can I send the current user to the edit form without overwritting the entity to edit?

  4. 4

    Symfony2, How can I pass parameters sort and direction using KnpPaginatorBundle and QueryBuilder

  5. 5

    I can't get SwiftMailer to send in a Symfony2 Command

  6. 6

    How do I send a data from Validator::extend() to Validator::replacer() so that my message can be more detailed?

  7. 7

    How can I access parameters defined in parameters.yml from within a twig template?

  8. 8

    How can I access parameters defined in parameters.yml from within a twig template?

  9. 9

    How do I pass a parameter to a validation constraint in Symfony2 - in yml

  10. 10

    How do I pass a parameter to a validation constraint in Symfony2 - in yml

  11. 11

    In Symfony2 how can I append a date to the assetic filenames

  12. 12

    How can I throw a 403 exception in Symfony2?

  13. 13

    How can I catch errors and exceptions in Symfony2/Silex?

  14. 14

    How can I get the action name in a Symfony2 controller?

  15. 15

    How can I dynamically set a parameter in Symfony2?

  16. 16

    How can I do to reload a symfony2 server with gulp?

  17. 17

    How can I inject doctrine into Symfony2 service

  18. 18

    How can i show the first published demands in Symfony2 ?

  19. 19

    How can I create complex reports with PHP / Symfony2?

  20. 20

    How can I join multiple tables in symfony2?

  21. 21

    How can I load templates from subdirectories in Symfony2?

  22. 22

    How can I get the action name in a Symfony2 controller?

  23. 23

    How can I dynamically set a parameter in Symfony2?

  24. 24

    How can I create complex reports with PHP / Symfony2?

  25. 25

    how can I change the implementation of FlashBag messages in Symfony2

  26. 26

    In Symfony2 how can I append a date to the assetic filenames

  27. 27

    How can i restrict acces in my page? Symfony2

  28. 28

    How can I join multiple tables in symfony2?

  29. 29

    How can I do to reload a symfony2 server with gulp?

HotTag

Archive