Skip to content

Commit

Permalink
BUGFIX Enforcing canEdit() checks in ComplexTableField_Popup - making…
Browse files Browse the repository at this point in the history
… form readonly if the current user can't edit (from r110857)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112863 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information
Sam Minnee committed Oct 19, 2010
1 parent d8a8635 commit 2d82ae6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions forms/ComplexTableField.php
Expand Up @@ -1060,6 +1060,8 @@ function __construct($controller, $name, $fields, $validator, $readonly, $dataOb
} }


parent::__construct($controller, $name, $fields, $actions, $validator); parent::__construct($controller, $name, $fields, $actions, $validator);

if(!$this->dataObject->canEdit()) $this->makeReadonly();
} }


function forTemplate() { function forTemplate() {
Expand Down
4 changes: 4 additions & 0 deletions tests/forms/ComplexTableFieldTest.php
Expand Up @@ -38,6 +38,8 @@ function testCorrectNumberOfRowsInTable() {
} }


function testAddingManyManyNewPlayer() { function testAddingManyManyNewPlayer() {
$this->logInWithPermission('ADMIN');

$team = DataObject::get_one('ComplexTableFieldTest_Team', "\"Name\" = 'The Awesome People'"); $team = DataObject::get_one('ComplexTableFieldTest_Team', "\"Name\" = 'The Awesome People'");


$this->post('ComplexTableFieldTest_Controller/ManyManyForm/field/Players/AddForm', array( $this->post('ComplexTableFieldTest_Controller/ManyManyForm/field/Players/AddForm', array(
Expand All @@ -57,6 +59,8 @@ function testAddingManyManyNewPlayer() {
} }


function testAddingHasManyData() { function testAddingHasManyData() {
$this->logInWithPermission('ADMIN');

$team = DataObject::get_one('ComplexTableFieldTest_Team', "\"Name\" = 'The Awesome People'"); $team = DataObject::get_one('ComplexTableFieldTest_Team', "\"Name\" = 'The Awesome People'");


$this->post('ComplexTableFieldTest_Controller/HasManyForm/field/Sponsors/AddForm', array( $this->post('ComplexTableFieldTest_Controller/HasManyForm/field/Sponsors/AddForm', array(
Expand Down

0 comments on commit 2d82ae6

Please sign in to comment.