Reputation: 4918
I'm using jms serializer bundle to serialize the form errors in our work api. From the user registration api we have a form built this way:
/**
* Creates the form fields
*
* @param FormBuilderInterface $builder The form builder
* @param array $options The array of passed options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('plainPassword', 'password', array('label' => 'asdasd'))
->add('name', 'text')
->add('email', 'email');
}
and submitting wrong informations we get:
"children": {
"plainPassword": {
"errors": [
"This value should not be blank."
]
}
}
Since the entity field is plainPassword is possible to have it named password and assigned to the plainPassword field?
Upvotes: 1
Views: 623
Reputation: 4918
Just found it, just use the 'property_path' option, this way:
$builder->add('password', 'password', array('property_path' => 'plainPassword'))
Upvotes: 2