disable 'add new' on sonata_type_collection

2,052 views
Skip to first unread message

Rich Birch

unread,
Mar 13, 2012, 1:36:08 PM3/13/12
to sonata...@googlegroups.com
Does anyone out there know how I can get rid of the green pluses that allow adding a new item to a collection? The native collectiontype has allow_add & allow_delete, but sonata_type_collection doesn't seem to notice those options.

Any assistance would be appreciated

César M.

unread,
Apr 3, 2012, 12:18:36 PM4/3/12
to sonata...@googlegroups.com
The sonata_type_collection insert a column of checkboxs to "delete". You select the rows to delete and when you SAVE the form, the marked row are deleted.
And I don't know about the option to add new item. If somebody can give us ideas, thanks.

duvan monsalve

unread,
Apr 19, 2012, 9:47:15 AM4/19/12
to sonata...@googlegroups.com
Hello, 
you can remove create router

  protected function configureRoutes(RouteCollection $collection)
    {
     
        $collection->remove('create');
    }

 to the admin you are relating with the sonata_type_collection, and the green plus would not be, the other posibility is to define your own template and make it as you want. 

Albert St Clair

unread,
May 5, 2014, 10:01:07 AM5/5/14
to sonata...@googlegroups.com
->add('store_orders', 'sonata_type_collection', array(
      'btn_add' => false
    ))

When you add a collection to Sonata admin forms, by default an "Add New" button is displayed, to prevent the "Add New" Button or "+" from displaying, set the add_btn key to FALSE in the array, which is the third parameter in the add function.

discu...@webdevilopers.net

unread,
Oct 24, 2014, 4:43:45 PM10/24/14
to sonata...@googlegroups.com
Any other method to remove the "delete" button than to override the template?

discu...@webdevilopers.net

unread,
Oct 24, 2014, 4:59:40 PM10/24/14
to sonata...@googlegroups.com
To remove the "delete" button add
'type_options' => array('delete' => false)

to the third parameter array.
Reply all
Reply to author
Forward
0 new messages