IphpFileStoreBundle
IphpFileStoreBundle copied to clipboard
File does not remove from sonata_type_collection
File is not deleted when you edit through sonata_type_collection. ->add('portraits', "sonata_type_collection", array( 'label' => false, 'required' => false, 'by_reference' => false, 'data_class' => null ), array( 'edit' => 'inline', 'inline' => 'table', 'allow_add' => true, 'allow_delete' => true ) ) The record is deleted, but the file is no.
+1
Maybe you should use orphanRemoval=true ? Example
<?php
namespace True\VnsBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
/**
* Main
*
* @ORM\Table(name="main", indexes={@ORM\Index(name="name_org", columns={"name_org"})})
* @ORM\Entity
* @ORM\Entity(repositoryClass="True\VnsBundle\Entity\MainRepository")
*/
class Main
{
/**
* Company employees
* @ORM\OneToMany(targetEntity="\True\VnsBundle\Entity\Empl", mappedBy="company",cascade={"persist"}, **orphanRemoval=true**)
**/
protected $empl;
}
<?php
namespace True\VnsBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Empl
*
* @ORM\Table(name="empl")
* @ORM\Entity
*/
class Empl
{
/**
* Employee company
* @ORM\ManyToOne(targetEntity="\True\VnsBundle\Entity\Main", inversedBy="empl")
* @ORM\JoinColumn(name="company_id", referencedColumnName="id", nullable=true)
*/
private $company;
}