Answer the question
In order to leave comments, you need to log in
Symfony2: How to create combi form from multiple entities?
Good afternoon. The task was to make a form from an entity. It seems nothing so complicated, but as it turned out, in some cases the number of entities from which it is necessary to make ONE form is more than 1 ... and then I got stuck.
so:
namespace TimeManagerBundle\Entity;
class Timepatch
{
//PROPERTIES
private $timepatchId;
private $timepatchStart;
private $timepatchEnd;
private $note;
// METHODS
public function getTimepatchId() { /* ... */ }
public function setTimepatchStart($timepatchStart) { /* ... */ }
public function getTimepatchStart() { /* ... */ }
public function setTimepatchEnd($timepatchEnd) { /* ... */ }
public function getTimepatchEnd() { /* ... */ }
public function setNote($note) { /* ... */ }
public function getNote() { /* ... */ }
}
<form>
Answer the question
In order to leave comments, you need to log in
Understood nothing.
Just to be clear, in the context of Symfony/forms it doesn't matter if you insert another form or an input into the form. The nesting can be arbitrarily large. If you just need to display two forms for two entities, make a third form and add these two to it.
In any case, you must have some kind of object for storing data, you can make a DTO with two fields in which your entities lie, then request processing will come down to creating a DTO object and binding the request using symphony.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question