php - How can i send parameters to translation file in symfony2 validator engine?

855

the {{ limit }} variables will not be replaced for the length when i use the translations files.

My variable with the validation stuff

/**
 * The Username
 *
 * @var string
 *
 * @Assert\NotBlank(message="user.username.notBlank")
 * @Assert\NotNull(message="user.username.notNull")
 * @Assert\Length(
 *      min = 2,
 *      max = 50,
 *      minMessage = "user.username.length.min",
 *      maxMessage = "user.username.length.max"
 * )
 * @\Doctrine\ORM\Mapping\Column(type="string", name="username")
 */
private $username;

My translation file:

user:
username:
notBlank: Der Benutzername darf nicht leer sein.
notNull: Der Benutzername darf nicht leer sein.
length:
  min: Der Benutzername muss mindestens {{ limit }} Zeichen lang sein.
  min: Der Benutzername darf maximal {{ limit }} Zeichen lang sein.

After the translation i got the error

"Der Benutzername muss mindestens {{ limit }} Zeichen lang sein."

instead of

"Der Benutzername muss mindestens 2 Zeichen lang sein."

420

Answer

Solution:

What is your version of Symfony?

Maybe a problem of indentation, try

user:
  username:
     notBlank: Der Benutzername darf nicht leer sein.
     notNull: Der Benutzername darf nicht leer sein.
     length:
       min: Der Benutzername muss mindestens {{ limit }} Zeichen lang sein.
       max: Der Benutzername darf maximal {{ limit }} Zeichen lang sein.



People are also looking for solutions to the problem: call to undefined function mysqli_connect()
Source

Share


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.


Similar questions

Find the answer in similar questions on our website.

16 php - How can i send parameters to translation file in symfony2 validator engine?
250 php - How to send parameters when redirect happens by htaccess
379 php - Database oracle cannot upload file or image
979 php - Sending a Delete request via laravel
186 php - Why can't I view the image after force downloading?
371 building a sql query string with php parameters
728 favicon - Save png file locally from a URL in PHP
283 php - Send checked table row value in array
906 php - Move file by rename()
629 php - Cannot set object value with merge value

People are also looking for solutions to the problem: php - Sending a Delete request via laravel

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.