简体   繁体   中英

SonataAdminBundle sonata_type_collection not showing field

I am using SonataAdminBundle. I want to add in my creation form ability to add one to many ralation objects. So I am trying to use sonata_type_collection like this:

$formMapper->add('attachments', 'sonata_type_collection', array(
                    'label' => 'Attachments',
                    // Prevents the "Delete" option from being displayed
                    'type_options' => array('delete' => false)
                ), array(
                    'edit' => 'inline',
                    'inline' => 'table',
                    'sortable' => 'position',
                ))

But my creation form renders only a label of the field, nothing more.

Thanks for all suggestions in advance :)

Try something like this:

        ->add('attachments', 'sonata_type_collection', array(
            'label' => 'Attachments',
        ), array(
            'class' => 'Model:Name',
            'target_entity' => '\\Namespace\\To\\Entity',
            'allow_delete' => false,
            'multiple' => true,
            'expanded' => false,
            'admin_code' => 'sonata.admin.setting',
            'edit' => 'inline',
            'inline' => 'table',
        ))

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