Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
44 lines (31 sloc) 1.91 KB

Deleting media

###Automatically display a checkbox for deletion

In your entity form type, you can use two options provided by the bundle to automatically display a non mapped checkbox under your media :

->add('document', 'vlabs_file', array(
            'required' => false,
            'add_del' => true,
            'del_label' => 'Delete ?'

###Real deletion

This part needs to be improved, actually the removal is not done automatically. You must always handle it in your controller.

For example, if your form is called image, you must call the following code to permanently delete the media :

if ($form->isValid()) {
    if($form->has('delImage') && $form->get('delImage')->getData() == true) {
    return $this->redirect($this->generateUrl('foo'));

The del file name will always be delFieldName

Note that if it's an image, it will also be removed from cache.