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.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

[SOLVED] An OR field in the summary_fields


Reply

2 Posts   186 Views

Avatar
lozhowlett

13 December 2013 at 1:57am Community Member, 146 Posts

Hi all

I have a issue with putting two fields in the summary_fields, its either 'Lead.FirstName' OR "Tenant.FirstName", what I dont want to happen is have 4 fields when two will do... is there a way to merge the fields, something like this...

static $summary_fields = array(
'DueDate',
'Lead.FirstName' . "Tenant.FirstName",
'Lead.LastName',
'Title',
'Complete'
);

Thanks

Avatar
lozhowlett

13 December 2013 at 3:24am Community Member, 146 Posts

Found it out...

Create a function then call that function, i.e.

function TaskSummaryName(){
if($this->LeadID){
$NameData = DataObject::get_one('Lead',"ID = '".$this->LeadID."'");
$FirstName = $NameData->Salutation . " ". $NameData->FirstName;
$LastName = $NameData->LastName . " (Landlord)";
}
if($this->TenantID){
$NameData = DataObject::get_one('Tenant',"ID = '".$this->TenantID."'");
$FirstName = $NameData->Salutation . " ". $NameData->FirstName;
$LastName = $NameData->LastName . " (Tenant)";
}

$Output = $FirstName . " " . $LastName;
return $Output;
}

Thanks