Question

I have table with this fields:

id, ch1, ch2, .., ch15

and 62 lines (id = 1 upto 62, and other fields = 0 by default). I need to create single form, where i can edit (not insert nor delete) all ch1-ch15 fields in all lines.

I've seen articles about embedded forms, but they're all about adding new line in database. I need only to edit existing lines.

And now the question: How can I bind each entity to each Form in Embedded form collection? Or there is another way to solve my problem?

Était-ce utile?

La solution

With embedded Forms you can only edit existing entities within their relations if you want to.

For example :

If you have a Person entity with multiple Address entities.

You need to implement a Person form and an Address form.

Inside of your Person Form you need to add a widget named after the attribute which stores the addresses and mark this attribute beein a subform (in this case the Address form)

If you save this form and call the $form->bind() method all of the values will be bind to the related entities.

For implementation details read the embedded forms article inside the docs

http://symfony.com/doc/current/book/forms.html#embedded-forms

hope it helps ;)

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top