Symfony2 - 如何直接在表单中验证类型?

I'm following this tutorial http://symfony.com/doc/current/book/forms.html#adding-validation

And added this to my form:

    $builder->add('email', null, array('label' =>  'userType.label.email','constraints' => array(new Email())));

This works perfectly fine.

But the following does not work:

    $builder->add('phoneNumber', null, array('label' =>  'userType.label.phoneNumber','required'  => true,'constraints' => array(new Type(array('type' => 'numeric')))));

How can i check if the input is numeric, right in the form?

By this:

->add('phoneNumber', 'integer', array('label' =>  'userType.label.phoneNumber','required'  => true));

When you pass null it will use the type you set in the model, is just a way to pass the 3rd parameter without overriding the second one.