I have this two tables (see pics below) mapped as follow:
class Brand
{
...
/**
* @var Company
*
* @ORM\ManyToOne(targetEntity="Company")
* @ORM\JoinColumn(name="companies_id", referencedColumnName="id")
*/
protected $company;
}
class Company
{
...
}
I have two admin classes: CompanyAdmin
and BrandAdmin
. I need to add support for add a new brand - create a new brand not link a existent one - from company admin but I have not idea in how to achieve this. The idea is:
- Create a company
- Add a button to company form where I can keep the current company ID and link that button to brand admin so I can easily add new brands to that company
I was reading sonata docs but EMBEDDING OTHER ADMINS section is not ready yet. Can any help me to get this done? I am stucked
I didn't fully understand your request, but from what I understood :
To create / select / delete company from brand
Documentation: https://sonata-project.org/bundles/doctrine-orm-admin/master/doc/reference/form_field_definition.html#advanced-usage-many-to-one
Add new brands in Company form
The fields displayed to create a new brand will be based on the configureFormFields of BrandAdmin.
Documentation : https://sonata-project.org/bundles/admin/master/doc/reference/form_types.html#sonata-type-collection