Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Form Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Table Field not displaying 'delete' option for non Administrators

Go to End

2 Posts   1467 Views


Community Member, 2 Posts

3 December 2010 at 10:46am

Edited: 03/12/2010 11:05am

Hi there,

Within my template I have a TableField that is only displaying the Delete icon when the user has Full Administrative rights.
Does anyone know why my contend editors can't delete data in the TableField?

Here's the section of code:

function getCMSFields() {

$fields = parent::getCMSFields();

//Program Rank Fields

$Top10ProgramsTable = new TableField('Top10ProgramsField', 'ProgramRank',array('Rank'=>'Rank','Program'=>'Program', 'Channel'=>'Channel', 'Audience'=>'Audience'), array('Rank'=>'TextField', 'Program'=>'TextField', 'Channel'=>'TextField', 'Audience'=>'TextField'), "MyNewsletterID",$this->ID);

$Top10ProgramsTable->setExtraData(array('MyNewsletterID' => $this->ID ? $this->ID : '$RecordID'));

$Top10ProgramsTable->setPermissions(array('edit', 'add', 'delete')); //adding and removing this line doesn't affect the outcome

return $fields;


static $has_many = array(
'Top10Programs' => 'ProgramRank');

class ProgramRank extends DataObject {

static $db = array(
'Rank' => 'Text',
'Program' => 'Text',
'Channel' => 'Text',
'Audience' => 'Text'


static $has_one = array(
'MyNewsletter' => 'TwoColumnNewsletter'


Thank you


Community Member, 6 Posts

30 March 2013 at 1:48pm

Hi there,

I was looking for a solution for the same problem via google but unfortunately I couldn't find one. So I started looking for some answers through the codes found in the core SS framework. I found out that on line 50 of the template, it shows that <% if Can(delete) %> ... <% end_if %> doesn't get executed because Can(delete) is always null within the context of the loop block (lines 44 to 52). So even if you have set the mode to "delete" explicitly via the setPermissions method, it doesn't work.

So the work around for this issue is to copy the file from the folder "sapphire/templates/" to your themes folder "themes/mysite". After you copy the template file, replace line 50 with <% if Top.Can(delete) %> to make sure the Can method refers to the context outside of the loop block.

You can actually directly edit the "" which is part of core SS but its bad practice. It is ideal to keep your core files untouched by copying templates that needs revisions to your themes folder. Anyways, the templates found in the themes folder has higher precedence than the ones found in the core SS templates folder.

I hope the above makes sense to anyone who have the same issue. :)