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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

relationAutoSetting = true hides unchecked items in the CMS

Go to End



Community Member, 10 Posts

2 June 2011 at 8:56pm

Hi, I have a HasManyComplexTableField object, and in the CMS I wanted the admin users to not have to 'check' a new item when they added them.

I knew if I left it like it is by default, I would have to explain to them that they need to check items when they add them in order to make them appear on the front end of the site, so I added the relationAutoSetting = true parameter, and that resolved that issue.

However, when I tested the CMS after adding several items, I unchecked one of them, just to confirm it hid it from the front end of the site, which it does.

But it also hides it from the table view in the CMS, so there's no way for an admin user to check it after they had unchecked it.

Here's the code that I am using:

function getCMSFields() {
$fields = parent::getCMSFields();

$minutes = new HasManyComplexTableField(
"MinutesDate" => "Date",
"MinutesGroup" => "Group",
"MinutesName" => "Name",
"MinutesDate DESC, MinutesGroup ASC"
// Set how many per page in the object list.

$minutes->setPermissions(array('add', 'edit', 'delete'));

$minutes->setFieldCasting(array('MinutesDate' => 'Date->Long'));

// Set the flag to live by default
$minutes->relationAutoSetting = true; // When this is set, it hides the unchecked items from the table?

$fields->addFieldToTab('Root.Content.Minutes', $minutes);

return $fields;

If I comment out the "$minutes->relationAutoSetting = true;" part, then in the list of items in the CMS, I can see both the checked and the unchecked items, so that resolves that issue, but obviously reverts my initial problem.

I can just go with the "having to explain that they need to check items for them to appear" option, but I was wondering if there's a solution to both of my issues?

Thanks for any help.