I use one general form type class to create all forms in my application. From controllers I only pass some parameters to it so that it knows which fields to render. For example:
$form = $this->createForm(new CommonType($repository, $queryResultSet), new UsersEntity(),
[
'action' => $this->generateUrl('user_edit'),
'attr' => ['class' => 'stdform'],
'repository_name' => 'AcmeBundle:Users'
]);
And then CommonType
class generates fields based on arrays from repository class.
However I need to add two entities now - the form has to contain fields from user
and shop
repositories/entities.
I thought about creating two forms here and connecting them, but I wouldn't be able to persist it to the database later.
How can I solve this problem?
I can't use form embedding because I have CommonType
class here in my case.