Jump to:

23477 Posts in 18941 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » relationAutoSetting = true hides unchecked items in the CMS

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

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

Page: 1
Go to End
Author Topic: 468 Views
  • pipworks
    Avatar
    Community Member
    10 Posts

    relationAutoSetting = true hides unchecked items in the CMS Link to this post

    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(
             $this,
             "Minute",
             "MinutesEntry",
             array(
                "MinutesDate" => "Date",
                "MinutesGroup" => "Group",
                "MinutesName" => "Name",
             ),
             "getCMSFields_forPopup",
             "",
             "MinutesDate DESC, MinutesGroup ASC"
          );
          $minutes->setAddTitle('minutes');
          // Set how many per page in the object list.
          $minutes->setPageSize(18);

          $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.

    468 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.