Jump to:

23379 Posts in 18298 Topics by 2867 members

General Questions

SilverStripe Forums » General Questions » [SOLVED] An OR field in the summary_fields

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

Page: 1
Go to End
Author Topic: 166 Views
  • lozhowlett
    Avatar
    Community Member
    146 Posts

    [SOLVED] An OR field in the summary_fields Link to this post

    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

  • lozhowlett
    Avatar
    Community Member
    146 Posts

    Re: [SOLVED] An OR field in the summary_fields Link to this post

    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

    166 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.