Search code examples
symfonysymfony-sonatasonatasonata-user-bundlesymfony-3.3

Sonata Admin Bundle: How to add a "Delete" button in form, to the entities on the nested entities list?


In the parent entity I can do something like that:

protected function configureFormFields(FormMapper $formMapper)
{

    $formMapper->add('units', 'sonata_type_collection', [
        'required' => true,
        'by_reference' => false,
        'label' => 'Units',
        'type_options' => [
            'delete' => true,
        ],
        'btn_add' => 'Add unit',
    ], [
        'edit' => 'inline',
        'inline' => 'table',
        'sortable' => 'position',
        'multiple' => true,
    ]);
}

This will display a delete checkbox. What is a proper way of having a simple "Delete" button next to every unit allowing for deleting it from the list? Is it possible to have something like this with minimal configuration?


Solution

  • I guess with minimal config is not possible. You should override a template or make your own