The Symfony docs list a number of field types that can be used when rendering forms. However, the docs also specify constrains that can be used for form validation. Can these two concepts be combined so that my Entity annotations will cause Symfony to use the correct form field type instead of just guessing?
For example, I have a User entity with a password field, which has the following annotations:
/**
* @ORM\Column(type="string", length=64)
* @Assert\Type("password")
*/
private $password;
I then use the FormBuilderInterface to render the field:
$builder
->add('password')
As you can see, I've not passed any additional options. Symfony renders this as a textfield, and seems to flatout ignore the password annotation.
How can I get Symfony to display this as a password field? Do I have to pass additional options using the FormBuilderInterface like this?
$builder
->add('password', 'password')
Is there any other way of doing this? Using annotations in my User entity seems like the perfect place to hint at the form field type, but Symfony just doesn't seem to take them into account when rendering the field.