开发者

Symfony Edit Specific Related Records

开发者 https://www.devze.com 2023-03-04 04:41 出处:网络
I have an app that I have a model that supports multiple add开发者_开发知识库resses, but upfront I only want to allow the user to add/edit one address.

I have an app that I have a model that supports multiple add开发者_开发知识库resses, but upfront I only want to allow the user to add/edit one address.

User
----
UserId

Address
----
UserId
Line1
...

I have the following to render the form for adding a new address, but how about existing records? What do I need to add to my configure method in the User form?

    $this->embedForm("address", new AddressForm());


Take a look at More with Symfony: Advanced Forms. This chapter outlines a good way to embed multiple forms when dealing with 1-to-many relationships and should more than cover explaining what you need to do.

0

精彩评论

暂无评论...
验证码 换一张
取 消