Symfony 2-验证消息

I use symfony validator assert, in my class subscription i have:

/**
 * @var string
 * @Assert\NotBlank(message="asasass")
 * */
    private $name;

Forms:

class SubscriptionType extends AbstractType{

    public function getName() {
        return 'Piotrek_subscription';
    }

    public function buildForm(FormBuilderInterface $builder, array $options) {
        $builder
                ->add('name', 'text', array(
                    'label' => 'Imię i nazwisko'

                ))
                ->add('email', 'text', array(

                ))
                ->add('save', 'submit', array(
                    'label' => 'Zapisz się'
                ));        }

    public function setDefaultOptions(OptionsResolverInterface $resolver) {
        $resolver->setDefaults(array(
            'data_class' => 'Piotrek\WitajBundle\Entity\Subscription'
        ));
    }
    }

And my controler:

$Subscription = new Subscription();

        $form = $this->createForm(new SubscriptionType(), $Subscription);


        return array(
            'form' => $form->createView(),

My form don't read the custom validate in comment. Imposes standard , but also do not know where. When I delete comment the ruler is still the same. So how do you change the text validation?

You constraint is a server side one, that means when you submit your form the page reloads and you will get the errors. But the message you see is the default HTML5 error message when you try to submit an empty field, because unless you mention otherwise inside your formbuiler, all fields will be rendered as required that's why you get the default hhtml 5 error message

You can do what want using:

Method 1: this will display your custom message "asasasas" after loading the page

set the required option as false

builder->add('name', 'text',array('required' => false )

Method 2:

Change the default htm5 error message from inside your SubscriptionType , something like this: ( I don't remember it exactly but this could point you to the right path)

builder->add('name' ,'text',array(
'attr'=>array('oninvalid'=>"setCustomValidity('bla bla.. ')")

Hope this works for you.

It looks like symfony does not read annotations in your code.

Probably you have not enabled annotations in app/config.yml

framework:
    validation: { enabled: true, enable_annotations: true }