Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File does not remove from sonata_type_collection #25

Open
rifats opened this issue Sep 11, 2014 · 2 comments
Open

File does not remove from sonata_type_collection #25

rifats opened this issue Sep 11, 2014 · 2 comments

Comments

@rifats
Copy link

rifats commented Sep 11, 2014

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.

@volkan
Copy link

volkan commented Feb 1, 2015

+1

@WarGot-by
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants