hi,
with the help of this tutorial:
http://www.ssbits.com/tutorials/2011/add-a-duplicate-button-to-model-admin/
I created a "Next" Button at the bottom of model admin.
The button calls the function "nextdataobject".
public function nextdataobject($data, $form, $request) {
$NextRecord = DataObject::get_by_id('SomeDataObject', $this->currentRecord->ID + 1);
$this->currentRecord = $NextRecord;
if(Director::is_ajax()) {
return new SS_HTTPResponse(
Convert::array2json(array(
'html' => $this->EditForm()->forAjaxTemplate(),
'message' => _t('ModelAdmin.PUBLISHED',"Next DataObject was loaded.")
)),
200
);
} else {
Director::redirectBack();
}
}
This works only if there are no breaks in the ID's. Because I just do a + 1 on the ID it could
be that one is missing cause of deletion. How to get just the next DO?
$this->nextRecord or something else would be great, does anyone have an idea?
But there is one more problem, the DataObject has a "has_one" relationship to an image.
If I click on "Next" it loads everything correct, but not the images ... it loads the images
of the last DataObject. Any idea why and how to solve?
Thx