arambalakjian / DataObject-as-Page

A SilverStripe module for displaying DataObjects as Pages
53 stars 27 forks source link

Can't save to the draft table #7

Closed MarcusDalgren closed 11 years ago

MarcusDalgren commented 12 years ago

I'm using DataObject as pages together with frontend editing so members of my site can add new dataobject as pages. When I save these objects no matter what I do it always only writes to the Object_Live table and not to the original Object table. This causes issues when trying to view the records in Modeladmin since Modeladmin won't show a record that isn't present in the original table.

I've tried calling writeToStage("Stage") explicitly but that still saves to the live table and not to the orignal table.

arambalakjian commented 12 years ago

Hi Marcus,

I think when first writing to the db you need to use the $forceInsert flag like so:

$Post->writeToStage('Stage', true);

At least that is how I do it with Posts on SSbits (although they are SiteTree, it should be the same with any versioned item).

Let me know if that works.

Aram

MarcusDalgren commented 12 years ago

Alright cool I'll set it up again and give it a go. BTW I extracted all the URL/Link functionality into a decorator. It might not be the greatest fit for your module but it feels like that kind of functionality (making a DataObject linkable) should be attachable to any DataObject you want.