简体   繁体   中英

Symfony and Sonata get Class with "pcode"

I'm having problem to get the Class which is called by the 'Add New' and the Modal Window.

The situation is that, I have a 'Add New' button on my entry with sonata_type_model:

->add('rfid', 'sonata_type_model', array(
                'class' => 'Admin\IdManageBundle\Entity\RFID',
                'property' => 'barcode'
            ))

when I click on 'Add New' it shows me a Modal Window, with which I can create new RFID.

but my RFID class has a barcode object that must be filled with the data of the class had the 'Add New' button!

I can handle the parent class with

->add('barcode', 'text', array(
                'data' => $this->getRequest()->get('pcode')
            ))

but I want to be able to get the Entity Manager of the responded 'pcode' In my case $this->getRequest()->get('pcode') returns:

admin_product_accessory_audio_audio.admin.audio

and it's not readable by $this->getConfigurationPool()->getContainer()->get('doctrine')->getRepository( $this->getRequest()->get('pcode') )

It has made me crazy!! :D

thanks in advance

use

$admin = $this->getConfigurationPool()->getAdminByAdminCode('admin_product_accessory_audio_audio.admin.audio');
$className = $admin->getClass();
$repo = $this->getConfigurationPool()->getContainer()->get('doctrine')->getRepository($class);

making sense ?

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