In SilverStripe I want to return two fields when I use map
in a DropdownField
.
I have a data object Teacher
with fields firstname
and lastname
. So in my DropdownField
I want to merge these two fields and pass them to map()
.
My current code looks like this:
public function getCMSfields() {
$fields = FieldList::create(TabSet::create('Root'));
$fields->addFieldsToTab('Root.Main', array(
DropdownField::create('TeacherID', 'Teacher')->setSource(Teacher::get()->map('ID', 'Firstname'))->setEmptyString('Select one')
);
// etc...
return $fields;
}
How is it possible to merge firstname
and lastname
and pass it inside map()
and return it to the DropdownField
.