[TYPO3-dev] extbase: replace an object by another

Anupam Chatterjee anupam at vrisini.com
Sun Aug 24 08:10:44 CEST 2014


On 8/21/2014 6:04 PM, Alex Bigott wrote:
> Hi,
>
> in extbase i would like to replace an object with a new one.
> The repository has the old and deprecated method "replace" which does
> exactely nothing.
>
> So what is the best way to update an object?
>
> I don't see how i could use the "update" method, since i am not able to
> set the uid of my unpersistet new object.
>
> Any tips or do i have to do it manually for each attribute in the object?
>
> Thanks
>
> Alex

Hi Alex,

One of the simplest ways to achieve what you seem to need here would be 
as follows:

- Get the model object corresponding to the record you wish to edit.

- Call the setter corresponding to the values you wish to replace with 
reference to the model object you have received. You do not need to call 
all setters, only the ones you need.

- use update with the model object.

That should be all!

Best regards,
Anupam Chatterjee

--
TYPO3 .... inspiring people to share!

TYPO3 Consultant @ Vrisini Infotech Pvt. Ltd.



More information about the TYPO3-dev mailing list