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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

All other Modules /

Discuss all other Modules here.

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

MultiSelectField example


Go to End


1572 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;
}