public function onPreSubmit(FormEvent $event)
    {
        $data = $event->getData();

        if ($data['file'] instanceof UploadedFile) {
            $event->getForm()->remove('remove');
        }

        if (empty($data['file']) && (!isset($data['remove']) || !$data['remove'])) {
            $event->setData($event->getForm()->getViewData());
        }
    }
public function onPreSubmit(FormEvent $event)
    {
        $data = $event->getData();

        if ($data['file'] instanceof UploadedFile) {
            $event->getForm()->remove('remove');
        }

        if (empty($data['file']) && (!isset($data['remove']) || !$data['remove'])) {
            $event->setData($event->getForm()->getViewData());
        }
    }
public function onPreSubmit ( FormEvent $ event ) { $ data = $ event -> getData ( ) ; if ( $ data [ 'file' ] instanceof UploadedFile ) { $ event -> getForm ( ) -> remove ( 'remove' ) ; } if ( empty ( $ data [ 'file' ] ) && ( ! isset ( $ data [ 'remove' ] ) || ! $ data [ 'remove' ] ) ) { $ event -> setData ( $ event -> getForm ( ) -> getViewData ( ) ) ; } }
Forbids to erase a value

@param FormEvent $event
Forbids to erase a value