10441 Posts in 2220 Topics by 1717 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 603 Views |
-
MultiSelectField: combine two strings?

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'))); -
Re: MultiSelectField: combine two strings?

28 April 2011 at 1:04am Last edited: 28 April 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:
$participantlist->map('ID','LongTitle');
Jamie
-
Re: MultiSelectField: combine two strings?

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.
| 603 Views | ||
|
Page:
1
|
Go to Top |


