arambalakjian / DataObject-as-Page

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

Versioned Objects are not saved when you click Publish #19

Closed petebacondarwin closed 11 years ago

petebacondarwin commented 11 years ago

I have set up my DOAP (it is a book object) so that it is Versioned. But now, when you click Publish it doesn't save the current state of the form but reverts it to the previous. I can't get my head around it! Have you come across this?

The correct data is being sent in the POST request. The doPublish method on the DOAP is being called. But $this inside doPublish does not show the changes. Moreover the Publish button is then disappearing and most recently all the buttons have disappeared. Any ideas?

If I just do a save then it saves it OK.


After some digging around, I think that your VersionedGridFieldDetailForm_Controller#publish method doesn't actually save the incoming data. The save method does this:

$form->saveInto($this->record);
$this->record->write();

But the publish method just calls

$record->doPublish();       

Perhaps it should call save first or do something similar to save?

arambalakjian commented 11 years ago

Now fixed