Domanda

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.

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top