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.

All other Modules

Discuss all other Modules here.

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

MultiSelectField: combine two strings?


3 Posts   812 Views


27 April 2011 at 8:52pm Community Member, 16 Posts

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')));


28 April 2011 at 1:04am (Last edited: 28 April 2011 1:05am), 121 Posts

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:




28 April 2011 at 5:15am Community Member, 16 Posts

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