I want to generate and persit multiple objects with only one form.
In My Form I have fields für Model Object House and fields for Model People, First 3 are for House and last 3 are for People.
Wenn I submit the form I want to create a Object for House and A Object for People. And the People should get the Relation to the house.
I tried this:
public function createAction(\Blubb\Blubb\Domain\Model\House $newHouse, \Blubb\Blubb\Domain\Model\People $newPeople) {
$this->houseRepository->add($newHouse);
$this->peopleRepository->add($newPeople);
$this->redirect('list');
}
Form looks like this:
how can I select which elements are for the House and which for the People?
Alternatively i tried set another form where i specified the name of Input like this:
name="house[housenr]"
--> Then I got this error: Required argument "newHouse" is not set.
Remove params from your createAction()
so you can use methods
$this->request->hasArgument('foo')
$this->request->getArgument('foo')
for custom collecting fields.