1

jmsシリアライザーバンドルを使用して、作業APIのフォームエラーをシリアル化します。ユーザー登録APIから、次のように作成されたフォームがあります。

/**
 * 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');
}

間違った情報を送信すると、次のようになります。

"children": {
    "plainPassword": {
        "errors": [
            "This value should not be blank."
        ]
    }
}

エンティティフィールドはplainPasswordなので、passwordという名前を付けて、plainPasswordフィールドに割り当てることができますか?

4

1 に答える 1

2

見つかったので、次のように「property_path」オプションを使用します。

$builder->add('password', 'password', array('property_path' => 'plainPassword'))
于 2013-03-22T16:26:04.850 に答える