Permalink
Browse files

API Show GridFieldEditButton even without edit permissions (for reado…

…nly forms)
  • Loading branch information...
1 parent 1848d7e commit bbc8e06d49fda5b87ccc780b57d8f9722e7c0393 @chillu chillu committed Dec 16, 2012
Showing with 8 additions and 7 deletions.
  1. +3 −3 forms/gridfield/GridFieldEditButton.php
  2. +5 −4 tests/forms/gridfield/GridFieldEditButtonTest.php
@@ -72,9 +72,9 @@ public function getActions($gridField) {
* @return string - the HTML for the column
*/
public function getColumnContent($gridField, $record, $columnName) {
- if(!$record->canEdit()){
- return;
- }
+ // No permission checks, handled through GridFieldDetailForm,
+ // which can make the form readonly if no edit permissions are available.
+
$data = new ArrayData(array(
'Link' => Controller::join_links($gridField->Link('item'), $record->ID, 'edit')
));
@@ -25,15 +25,16 @@ public function setUp() {
$this->form = new Form(new Controller(), 'mockform', new FieldList(array($this->gridField)), new FieldList());
}
- public function testDontShowEditLinks() {
+ public function testShowEditLinks() {
if(Member::currentUser()) { Member::currentUser()->logOut(); }
$content = new CSSContentParser($this->gridField->FieldHolder());
// Check that there are content
$this->assertEquals(3, count($content->getBySelector('.ss-gridfield-item')));
- // Make sure that there are no edit links
- $this->assertEquals(0, count($content->getBySelector('.edit-link')),
- 'Edit links should not show when not logged in.');
+ // Make sure that there are edit links, even though the user doesn't have "edit" permissions
+ // (he can still view the records)
+ $this->assertEquals(2, count($content->getBySelector('.edit-link')),
+ 'Edit links should show when not logged in.');
}
public function testShowEditLinksWithAdminPermission() {

0 comments on commit bbc8e06

Please sign in to comment.