Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

- Add a new delete button function to allow for improved javascript a…

…ction to be applied so as to return empty search so that results list is displayed after deleting item.

- Added EditForm to remove forward and back buttons which I have found to be buggy at best i.e. if back button is pressed after object is created it doesn't take you back to the list.
- Also I have removed the default save and delete buttons so that I can reorder them to provide similarity between this and pages on the Sitetree.
  • Loading branch information...
commit 18052ca474fc267bcf419e49bc804a9cc4ab6fd6 1 parent 09aebbd
@jamesbolitho jamesbolitho authored
Showing with 32 additions and 4 deletions.
  1. +32 −4 code/ModelAdmin/DataObjectAsPageAdmin.php
View
36 code/ModelAdmin/DataObjectAsPageAdmin.php
@@ -33,7 +33,24 @@ public function doPublish($data, $form, $request)
} else {
Director::redirectBack();
}
- }
+ }
+
+ public function doSaveToDraft($data, $form, $request) {
+ $form->saveInto($this->currentRecord);
+
+ try {
+ $this->currentRecord->write();
+ } catch(ValidationException $e) {
+ $form->sessionMessage($e->getResult()->message(), 'bad');
+ }
+
+ // Behaviour switched on ajax.
+ if(Director::is_ajax()) {
+ return $this->edit($request);
+ } else {
+ Director::redirectBack();
+ }
+ }
public function doUnpublish($data, $form, $request)
{
@@ -51,7 +68,7 @@ public function doUnpublish($data, $form, $request)
}
}
- public function doDelete($data, $form, $request)
+ public function doDeleteItem($data, $form, $request)
{
$record = $this->currentRecord;
@@ -61,7 +78,7 @@ public function doDelete($data, $form, $request)
$record->doDelete();
if(Director::is_ajax()) {
- $this->edit($request);
+ $this->edit($request);
} else {
Director::redirectBack();
}
@@ -80,5 +97,16 @@ public function duplicate($data, $form, $request) {
} else {
Director::redirectBack();
}
- }
+ }
+
+ public function EditForm() {
+ $form = parent::EditForm();
+ $fields = $form->Actions();
+ $fields->removeByName('action_doSave');
+ $fields->removeByName('action_doDelete');
+ $fields->removeByName('action_goForward');
+ $fields->removeByName('action_goBack');
+ $form->setActions ($fields);
+ return $form;
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.