21281 Posts in 5729 Topics by 2600 members
General Questions
SilverStripe Forums » General Questions » remove "Add" button from complexTable in cms (solved)
General questions about getting started with SilverStripe that don't fit in any of the categories above.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 785 Views |
-
remove "Add" button from complexTable in cms (solved)

23 July 2010 at 8:36am Last edited: 25 July 2010 8:01am
I want to remove the "Add ..." Button from the CMS display for a page that belongs to a many-many relationship. I only want someone to be able to click the checkbox to associate the Model object, but not create a new Model object from this page.
I'm calling it like this:
$modulesTablefield = new ManyManyComplexTableField(
$this,
'Modules',
'Module',
array(
'Title' => 'Title',
'Headline' => 'Headline'
),
'getCMSFields_forPopup'
);
$fields->addFieldToTab('Root.Content.Module',$modulesTablefield);EDIT
Adding the following code to the page controller removes the add button.$modulesTablefield->setPermissions(array(
'view'
));Chris.b
-
Re: remove "Add" button from complexTable in cms (solved)

23 July 2010 at 8:58am
just a guess but add...
function canAdd(){return false;}
function canCreate(){return false;}...to the data object?
-
Re: remove "Add" button from complexTable in cms (solved)

23 July 2010 at 9:35am
Thanks swaiba. That didn't work, but the idea is what I want. Actually I don't want to remove the button at the data object level, just from the display in the cms on certain page types.
But that has me looking in that direction now.
Thanks,
Chris.b
-
Re: remove "Add" button from complexTable in cms (solved)

24 July 2010 at 11:10pm
You can set the permissions of a CTF one of those being add. See http://doc.silverstripe.org/tablelistfield#permissions for an example of how to set it. In your case you probably want only view, maybe edit.
-
Re: remove "Add" button from complexTable in cms (solved)

25 July 2010 at 8:02am
Thanks Will!
$modulesTablefield->setPermissions(array(
'view'
));fixed it!
| 785 Views | ||
|
Page:
1
|
Go to Top |



