문제

I have a yml file for the user form validation (a form like many others):

# src/User/RegBundle/Resources/config/validation.yml
    User\RegBundle\Entity\User:
      properties:
        name:
          - NotBlank: ~
          - Length:
              min: 2
              max: 255
              minMessage: error_min_message
              maxMessage: error_max_message

The form is rendered into the twig like below

//...
{{ form_row(form.name) }}
{{ form_row(form.surname) }}
{{ form_row(form.gender) }}
{{ form_row(form.email) }}
//...

My symfony2 website has a multilanguage structure and there are the messages.mylang.xliff file for the words translation. All works right. My question is whether there's a way to insert the "error_min_message" into the messages.mylang.xliff or there are others ways to translate that messages.

도움이 되었습니까?

해결책

Validation strings go to validators.LANG.FORMAT instead of messages.LANG.FORMAT. Don't forget to clear the cache after you add a new translation file.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top