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.

Customising the CMS /

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

Empty TreeMultiselectField and $many_many


Go to End


969 Views

Avatar
hello_world

Community Member, 19 Posts

26 October 2011 at 3:14am

Hi,
I have defined two classes: Products and Solutions.
The Product has many Solutions so I defined relationship many_many (static $has_many = array( "Solution" => "Solutions");).
Just to able add Solutions to Products in getCMSField, I defined TreeMultiselectFiel.

$MapSolutions = DataObject::get("SiteTree","`ClassName`='Solutions'")->toDropDownMap('ID','Title');
$fields->addFieldToTab("Root.Content.Main", new TreeMultiselectField('Solution','Description',$MapSolutions);,'Content');

During saving relationship are created - works fine. But when I refresh (F5 or CTRL+R) in TreeMultiselectField I can`t see which Solutions will be selected before write Content.

Thanks for help