OroPlatform Forums

Covering OroPlatform topics, including community updates and company announcements.

Forums Forums OroPlatform OroPlatform – How do I? Questions Form remove one-to-many entities

This topic contains 4 replies, has 2 voices, and was last updated by  Anonymous 6 years, 2 months ago.

Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.

  • Creator
  • #35786


    I have created a form with a collection of another entity (Question with Answers). I think is similar to Contacts and Address entities in Orocrm.

    The problem is that I’m not be able to “delete” answers (only add). The relation is OneToMany (question -> answer) and I read in the symfony book that this operation is not automatically accomplished by doctrine.

    Where in the orocrm code this operation is performed? I have missed anything?

    Best regards and excuse me for the very bad english,


Viewing 4 replies - 1 through 4 (of 4 total)
  • Author
  • #35787

    Alexandr Smaga

    Hello. Yes I think you missed orphan removal (see). This options requires doctrine to check if entity that has been extracted as a part of collection and now detached from it then it should be removed as orphan.



    Hi Alexandr, thank you for the answer.

    I already have “orphanRemoval” but the problem persist. This is my entity Question:

    * @var Collection
    * @ORM\OneToMany(targetEntity=”Answer”,
    * mappedBy=”question”, orphanRemoval=true
    * )
    private $answers;

    but if I post a form without answers, these are not deleted from DB. Have I missed something?



    Alexandr Smaga

    Do you have method removeAnswer ?

    It should looks like this



    Yes, this function (togheter with addAnswer(), getAnswer(), and setAnswer() plus __construct()) is generated by doctrine automagically based on yaml file configuration.

Viewing 4 replies - 1 through 4 (of 4 total)

The forum ‘OroPlatform – How do I? Questions’ is closed to new topics and replies.

You will be redirected to [title]. Would you like to continue?

Yes No