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.

All other Modules /

Discuss all other Modules here.

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

MultiSelectField example


Go to End


1770 Views

Avatar
klikhier

Community Member, 150 Posts

25 June 2009 at 8:43pm

For an example of how to use the MultiSelectField module:

static $many_many = array ('Things'=>'ThingPage');

function getCMSFields() {
   $fields = parent::getCMSFields();
   $fields->addFieldToTab(
     "Root.Content.Related",
     new MultiSelectField(
       "Things", // Relationship that the field controls
       "Related Things", // Label for field
       "ThingPage", // Related class
       "ID", // Mapped data field in related class (normally ID)
       "Title" // Mapped label field in related class (often Title)
     )
   );
   return $fields;
}