I have two entities with OneToOne relation : Objectif and Image .
in sonata admin bundle , i would like to be able to remove an image from an objective ( image is defined in formField with a sonata_type_admin.
I'm able to tick the checkbox "delete" but when i click on update button, nothing change, the image entity is still here .here is my code :
/** objectiveAdmin form field **/
/**
* @param FormMapper $formMapper
*/
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
->with("General")
->add('titre')
->add('description')
->with("Icone")
->add('image', 'sonata_type_admin', array(), array('required' => false, 'edit' => 'admin'))
;
}
/** objective entity class **/
/**
* @ORM\OneToOne(targetEntity="acme\Bundle\Entity\Image" , cascade={"persist"} , orphanRemoval=true )
*/
private $image;
and finally a capture of my sonata admin objectif page :
thx so much for any answers !