简体   繁体   中英

Include two entities in a single class Sonata Admin Bundle

I have a Product table and a Brand table. Brand table contains a product id. I am using Sonata admin bundle to set up the admin. I have Product admin class and Brand admin class. Now I am able to list both the tables. When clicked on one of the products, an edit screen comes. What I want now is, I want to display the corresponding Brand table entries also along with this screen and also be able to add new brands. Please help me on this.

I have tried something with sonata_type_admin, but could be of no help.

The code below solves the issue.

->add('brands', 'sonata_type_collection', array(
                        'by_reference' => true
        ), array(
                        'edit' => 'inline',
                        'inline' => 'table',
                        'sortable' => 'position',
        ))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM