ssossossosso

Forums

Covering OroCRM topics, including community updates and company announcements.  Subscribe

This topic contains 4 replies, has 2 voices, and was last updated by  Anonymous 3 years, 1 month ago.

  • Creator
    Topic
  • #5137

    Anonymous

    Hi,
    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,

    Carlo

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

    Alexandr Smaga
    Participant

    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.

    #5166

    Anonymous

    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?

    C.

    #5168

    Alexandr Smaga
    Participant

    Do you have method removeAnswer ?

    It should looks like this

    #5169

    Anonymous

    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)

You must be logged in to reply to this topic.