Many-to-One or One-to-One relations with sonata_type_model_list
->add('client', 'sonata_type_model_list', [
'btn_add' => $this->trans('admin.button.add_client'),
'btn_list' => $this->trans('admin.button.list'),
'btn_delete' => 'Delete button',
'btn_catalogue' => $this->translationDomain,
'label' => $this->trans('admin.label.client'),
'required' => true,
], [
'placeholder' => $this->trans('admin.placeholder.no_client'),
])
The line 'btn_delete' => 'delete button'
gives you delete button
right of you one-to-one entity.
In this example I use an entity ClientCard which has one-to-one relation to Client entity.
List view.
By default you have delete button in list view.
Delete - is one of the batch actions. If you want to disable this action (and all other as well) you have to overwrite
getBatchActions
method
/**
* @return null
*/
public function getBatchActions()
{
return null;
}
Edit mode.
By default you have delete button in edit mode.
If you want completely disable the delete action, then you can overwrite
configureRoutes
method:
/**
* @param RouteCollection $collection
*/
protected function configureRoutes(RouteCollection $collection)
{
$collection->remove('delete');
}
Hope it will help.