开发者

Symfony: Save multiple same objects

开发者 https://www.devze.com 2023-02-02 18:59 出处:网络
I have a page that shows 3 Objects (they are the same class). I want to save them. Unfortunaly only the latest one gets updated. All other开发者_StackOverflow中文版 seems to be invalid.

I have a page that shows 3 Objects (they are the same class). I want to save them. Unfortunaly only the latest one gets updated. All other开发者_StackOverflow中文版 seems to be invalid.

So my idea was to give them unique names: testObject_1[text1], testObject_2[text1]. This works as I can see it in the source code.

But how can I pass this name to form->save() in order to get the POST-reply filtered by this name (testObject_1) and then save it?

Or is there something more easier?

Thank you Tobias Kaminsky


I solved it:

$temp->bind($request->getParameter("testObject_$i"), $request->getFiles("testObject_$i"));

(where $i is an Index stored in the database)

0

精彩评论

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

关注公众号