26 January 2010 at 2:43am
I'm trying to figure out how to show two fields side by side in a single, mapped dropdown. For example in the code below I want the dropdown to display the combination of FirstName + LastName (and Map it to that Author's ID). I can work with a single field (either FirstName OR LastName) but can't seem to concatenate them both to be displayed in the Dropdown...
//This works fine but I need to include the LastName also
$authorData = DataObject::get('Author');
$AuthorSource = $authorData->toDropDownMap('ID', 'FirstName', 'Select Author');
29 January 2010 at 7:34am
Well an you could also create an extra column on your DataObject that contains the full name and fill it with an onBeforeWrite instead of manually filling it in. Thats a quick in-elegant fix. My only other idea is even more complex. You could output the first name and last name to arrays and marry them back up, but I don't know if you can Map and array to drop down