I am currently performing validation using the Symfony Validator component using annotations in the Entity class.
In the Symfony documentation, you can use certain placeholders to pass variables through a message, and these messages can be translated by the Translator component.
So, for example, you can write the following annotation:
/** * Assert\Length( * min = 5, * max = 10, * minMessage = "Title too short: {{ limit }}", * maxMessage = "Title too long: {{ limit }}" */ protected $title;
This works great, but I was wondering what types of placeholders are available to you? Is it possible to create custom placeholders?
I know that the {{ value }} placeholder exists (and works), but it is not on the Symfony documentation page on how to use length checking.
I would like to use a placeholder such as {{ key }} or {{ name }} to pass in the technical name of the field (in this case "title"), so I can write minMessage as minMessage = "{{ field }} too short: {{ limit }}"
I tried to check the standard components for Symfony to see how these placeholders are handled, but I cannot find the correct list of variables available to me.
Please help me! T_T
variables placeholder validation symfony
Stackoververflowser
source share