1

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?

alex88
  • 4,788
  • 4
  • 39
  • 60

1 Answers1

2

Just found it, just use the 'property_path' option, this way:

$builder->add('password', 'password', array('property_path' => 'plainPassword'))
alex88
  • 4,788
  • 4
  • 39
  • 60