Permalink
Browse files

MINOR Making canEdit() method optional on objects handled by LeftAndM…

…ain subclasses
  • Loading branch information...
1 parent 5bd43af commit 3c544340ee6142bd4b7a85a2e8aff59306f2af66 @chillu chillu committed Apr 19, 2011
Showing with 3 additions and 3 deletions.
  1. +3 −3 admin/code/LeftAndMain.php
@@ -454,7 +454,7 @@ public function Content() {
public function getRecord($id) {
$className = $this->stat('tree_class');
- if($id instanceof $className) {
+ if($className && $id instanceof $className) {
return $id;
} else if(is_numeric($id)) {
return DataObject::get_by_id($className, $id);
@@ -764,7 +764,7 @@ public function getEditForm($id = null, $fields = null) {
$actions = $record->getCMSActions();
// add default actions if none are defined
if(!$actions || !$actions->Count()) {
- if($record->canEdit()) {
+ if($record->hasMethod('canEdit') && $record->canEdit()) {
$actions->push(new FormAction('save',_t('CMSMain.SAVE','Save')));
}
}
@@ -794,7 +794,7 @@ public function getEditForm($id = null, $fields = null) {
$form->unsetValidator();
}
- if(!$record->canEdit()) {
+ if($record->hasMethod('canEdit') && !$record->canEdit()) {
$readonlyFields = $form->Fields()->makeReadonly();
$form->setFields($readonlyFields);
}

0 comments on commit 3c54434

Please sign in to comment.