DavidDG
DavidDG

Reputation: 57

Updating an entity Symfony 2.6

I'm trying to update an entity. I have a form, who returns an array to my formHandler.

There is my onSuccess()

public function onSuccess($createIndicatorModelFormModel)
{
    $this->em->persist($this->indicatorModelTransformer->transform($createIndicatorModelFormModel));
    $this->em->flush();
}

I can't persist an array, that's why i've made an transformer.

The problem is when i'm trying to persist or merge. He is trying to INSERT an new row.. What can i do ?

Upvotes: 1

Views: 48

Answers (1)

Puya Sarmidani
Puya Sarmidani

Reputation: 1289

You have to call method persist() when initializing a new object. Use it without persisting it when updating. To resolve this issue i need more code. Or my guess based on your question is to simply commenting out the persist part.

Upvotes: 1

Related Questions