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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Form Questions /

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

TreeMultiselectField issue with selected item being a sub-child of the visible items.


Go to End


1308 Views

Avatar
AntonPunith

Community Member, 1 Post

27 February 2015 at 8:08pm

Edited: 27/02/2015 8:14pm

I have a many-many relationship in a page in a SS 3.1 installation and have verified that it works with GridField perfectly. I wanted to change it to TreeMultiselectField so that all Objects under a landing page show in the tree. It works perfectly for the first level, and even allows to select the second level and save. But when you try to edit it if the second level element is checked, as soon as the list is populated, you lose selection on second level. Attaching the screenshot for reference.

  private static $many_many=array(
    'Industries'=>'IndustryPage'
  );
.
.
    $IndustriesLandingPage = IndustriesLandingPage::get()->First();
    $IndustriesField = new TreeMultiselectField('Industries', 'Select areas of Industries this article applies to', 'SiteTree');
    if($IndustriesLandingPage){
      $IndustriesField->setTreeBaseID($IndustriesLandingPage->ID);
    }
    $fields->addFieldToTab('Root.ServicesAndIndustries', $IndustriesField);

Attached Files