Hey Simone,

Why don't you just fix that in the API of your entity?

public function addPhoneNumber($phoneNumber)
{
    if ($phoneNumber->isFavorite()) {
        foreach ($this->phoneNumbers as $phoneNumber) {
            $phoneNumber->setFavorite(false);
        }
    }

    $this->phoneNumbers->add($phoneNumber);
}

Marco Pivetta

http://twitter.com/Ocramius

http://ocramius.github.com/


On 23 April 2014 17:32, Simone Fumagalli <[email protected]> wrote:

> I've a OneToMany relations. Let's say User->PhoneNumbers (the real
> scenario is different, this is just a simplified version)
> PhoneNumber has 2 property: number and favourite (boolean).
> A user can have only one favourite phone number.
>
> Is it possible that when I add a PhoneNumber to a User with favourite set
> to true Doctrine automatically set favourite to false for all the other
> PhoneNumber of the user ?
>
> Thanks
>
> --
> Simone
>
> --
> You received this message because you are subscribed to the Google Groups
> "doctrine-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/doctrine-user.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to