Symfony2: How to translate custom error messages in form types?

后端 未结 4 805
梦谈多话
梦谈多话 2021-02-12 15:41

I need to translate the error messages from my form type. Here is my form Type code:

class ReferFriendType extends AbstractType {

public function buildForm(Form         


        
4条回答
  •  忘了有多久
    2021-02-12 16:16

    The replacements are not set in the validation.yml file but by the Validator.

    validators.en.yml

    noFirstnameMinLimit: Please provide at least {{ limit }} characters
    

    validation.yml

    Acm\AddressBundle\Entity\Address:
        properties:
            firstname:
                - Length:
                    min: 3 
                    minMessage: "noFirstnameMinLimit"
    

    This works for me with Symfony 2.4

提交回复
热议问题