[TYPO3-mvc] Copy object and add to repository
Fabian Fisahn
fisahn at its-immaterial.com
Wed Apr 6 16:06:18 CEST 2011
Hi Franz,
thanks for your answer, but
On 06.04.11 15:53, Franz Koch wrote:
> Hey,
>
>> I try to copy an object and add it to the database:
>>
>> ------------------
>> // Change product title
>> $product->setProductName('[Copy of] ' . $product->getProductName());
>>
>> $this->productsRepository->add($product);
>
> $newProduct = clone($product);
> $newProduct->setProductName('[Copy of] ' . $product->getProductName());
>
> $this->productsRepository->add($newProduct);
>
>
> That should do the trick. The magic lies in "clone" which is creating a
> new "identity".
i got the exception
"The uid "1037" has been modified, that is simply too much. "
The entry with the uid 1037 ist in the database but its empty.
Did I forget something or need to set defaults or something like this?
Fabian
More information about the TYPO3-project-typo3v4mvc
mailing list