IphpFileStoreBundle icon indicating copy to clipboard operation
IphpFileStoreBundle copied to clipboard

File does not remove from sonata_type_collection

Open rifats opened this issue 10 years ago • 2 comments

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.

rifats avatar Sep 11 '14 12:09 rifats

+1

volkan avatar Feb 01 '15 18:02 volkan

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;
}

WarGot-by avatar Mar 09 '15 21:03 WarGot-by