Does anyone out there know how I can get rid of the green pluses that allow adding a new item to a collection in the sonata admin forms? The native collectiontype has allow_add & allow_delete, but sonata_type_collection doesn't seem to notice those options.
I have tried the following:
->add('store_orders', 'sonata_type_collection', array(), array(
'type_options' => array('allow_add' => false),
))
which has no effect
->add('store_orders', 'sonata_type_collection', array(
'allow_add' => false
))
which gives an error 'The option "allow_add" does not exist'
->add('store_orders', 'sonata_type_collection', array(
'type_options' => array('allow_add' => false)
))
which also gives an error 'The option "allow_add" does not exist'
I'd also like to remove the delete checkboxes next to each item in the collection. I presume the answer to that lies in a similar area.
Any assistance would be greatly appreciated.
Try this
->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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With