Symfony2 - Validation not working for embedded Form Type

后端 未结 8 1410
北海茫月
北海茫月 2020-12-07 12:59

I have a form that combines two entities (User and Profile).

Validation seems to work on the first part of the form that comes form the User Entity and is the basis

8条回答
  •  青春惊慌失措
    2020-12-07 13:35

    A note to those using Symfony 3.0 and up: the cascade_validation option has been removed. Instead, use the following for embedded forms:

    $builder->add('embedded_data', CustomFormType::class, array(
        'constraints' => array(new Valid()),
    ));
    

    Sorry for adding to this old thread with a slightly off-topic answer (Symfony 3 vs. 2), but finding this information here would have saved me a few hours today.

提交回复
热议问题