diff --git a/forms/ComplexTableField.php b/forms/ComplexTableField.php index b4dc46b4c..f1b70861f 100755 --- a/forms/ComplexTableField.php +++ b/forms/ComplexTableField.php @@ -1060,6 +1060,8 @@ class ComplexTableField_Popup extends Form { } parent::__construct($controller, $name, $fields, $actions, $validator); + + if(!$this->dataObject->canEdit()) $this->makeReadonly(); } function forTemplate() { diff --git a/tests/forms/ComplexTableFieldTest.php b/tests/forms/ComplexTableFieldTest.php index c62c5b7f6..b05d12105 100644 --- a/tests/forms/ComplexTableFieldTest.php +++ b/tests/forms/ComplexTableFieldTest.php @@ -38,6 +38,8 @@ class ComplexTableFieldTest extends FunctionalTest { } function testAddingManyManyNewPlayer() { + $this->logInWithPermission('ADMIN'); + $team = DataObject::get_one('ComplexTableFieldTest_Team', "\"Name\" = 'The Awesome People'"); $this->post('ComplexTableFieldTest_Controller/ManyManyForm/field/Players/AddForm', array( @@ -57,6 +59,8 @@ class ComplexTableFieldTest extends FunctionalTest { } function testAddingHasManyData() { + $this->logInWithPermission('ADMIN'); + $team = DataObject::get_one('ComplexTableFieldTest_Team', "\"Name\" = 'The Awesome People'"); $this->post('ComplexTableFieldTest_Controller/HasManyForm/field/Sponsors/AddForm', array(