mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
MINOR Making canEdit() method optional on objects handled by LeftAndMain subclasses
This commit is contained in:
parent
5bd43af85f
commit
3c544340ee
@ -454,7 +454,7 @@ class LeftAndMain extends Controller {
|
||||
|
||||
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 @@ class LeftAndMain extends Controller {
|
||||
$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 @@ class LeftAndMain extends Controller {
|
||||
$form->unsetValidator();
|
||||
}
|
||||
|
||||
if(!$record->canEdit()) {
|
||||
if($record->hasMethod('canEdit') && !$record->canEdit()) {
|
||||
$readonlyFields = $form->Fields()->makeReadonly();
|
||||
$form->setFields($readonlyFields);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user