Jump to:

3461 Posts in 1065 Topics by 740 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Override the "Created" property

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 858 Views
  • rob.s
    Community Member
    78 Posts

    Override the "Created" property Link to this post


    because of migrating data to a new SS Website i have to import data.
    The import itself is handled by a custom "Task".

    I need to set the "Created" (datetime) property while importing.
    But SS ignores the set values.


    $o = new CustomDataObject();
    $o->Created = '2000-01-01 00:00:00';

    After saving the Created datetime is always the datetime of execution - NOT my given value.
    I do not want to add a new property like "CreatedAt" to the DataObject.

    Is it possible to override this behaviour ?


  • martimiz
    Forum Moderator
    1088 Posts

    Re: Override the "Created" property Link to this post

    the write() function will set Created to 'now' on every new insert. You could maybe use the return ID to update the record after it's written...

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.