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

Customizing the TreeMultiselectField in the CMS


Go to End


1089 Views

Avatar
copernicus

Community Member, 4 Posts

5 November 2010 at 4:41am

Edited: 05/11/2010 4:42am

In the admin I have as an option when you create a new item to let you choose which categories it belongs to through a TreeMultiselectField.

$treeMenu = new TreeMultiselectField('Categories', 'What categories does this belong in?', 'PortfolioCategory');

PortfolioCategory is a class that extends Page.

Now, when you click on the drop down to select a category, it just shows the entire site tree. Is there a way to customize it to say, only show Pages of type "PortfolioCategory"?

Also, is there a way to have an option in the drop down automatically selected by default? Ideally, when you click "Add New Item", the drop down is there and one of the options is already selected and cannot be unselected.