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: combine two strings?

Go to End

3 Posts   1362 Views


Community Member, 16 Posts

27 April 2011 at 8:52pm

Hi, I am using the MultiSelectField module (see code). Is it possible two show a combination of for example 'Title' and a second text field (in my case 'Edition'. Something like 'Title . "and" . Edition'?

$participantlist = DataObject::get('Participant','','Title ASC'); 
$fields->addFieldToTab('Root.Content.Main', new MultiSelectField('Participants', 'Active participants', $participantlist->map('ID','Title')));


121 Posts

28 April 2011 at 1:04am

Edited: 28/04/2011 1:05am

Easiest way to do it is to create a method in your Participant class:

class Participant extends DataObject {
  function getLongTitle() {
    return $this->Title . ' and ' . $this->Edition;

and then you can call:




Community Member, 16 Posts

28 April 2011 at 5:15am

Thank you. Very useful, because I have a long list of participants and some of them have almost the same 'Title' field.