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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

[SOLVED] An OR field in the summary_fields


Go to End


2 Posts   509 Views

Avatar
lozhowlett

Community Member, 151 Posts

13 December 2013 at 1:57am

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

Community Member, 151 Posts

13 December 2013 at 3:24am

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