Export Array of entries in modifyEntryTableAttributes I am trying to return an array of selected entries in the list view, but so far I can only get first() and last() to export the names, since it's only grabbing one entry. I would like to get a comma separated list of entries tied the that specific entry.

I have tried using find() and find()-&gt;title but it gives me an error.

Here's what I have right now.

    public function getEntryTableAttributeHtml(EntryModel $entry, $attribute){
     if ($attribute == 'sponsorEntries'){
      return '&lt;span&gt;'.$entry-&gt;sponsorEntries-&gt;first().'&lt;/span&gt;';
     }
    }


and then I call it:

        // Artists
     public function modifyEntryTableAttributes(&amp;$attributes, $source){
      if ($source == 'section:9'){
        $attributes['sponsorEntries'] = Craft::t('Sponsor');
      }
     }


but I would like to get return all the entries, not just the first() one like the screenshot below illustrates.
You'll need to use the find method rather than first and last, in order to pull all the entries.

Then, you'll have to loop through the entries, appending their titles to a variable which will be used for the attribute's HTML value in the list view.

Here, I'm pushing the entry titles to an array called $tempArray. After looping, the array is joined and returned as a comma separated list:

public function getEntryTableAttributeHtml(EntryModel $entry, $attribute)
{
    if ($attribute == 'sponsorEntries')
    {
        if ($sponsorEntries = @$entry-&gt;$attribute-&gt;find())
        {
            $tempArray = [];
            foreach ($sponsorEntries as $sponsorEntry)
            {
                $tempArray[] = $sponsorEntry-&gt;title;
            }
            // Will return "Awesome Entry, Another Awesome Entry"
            return implode(', ', $tempArray);
        }
    }
}


If you want to, you can also make the entry titles in the list view clickable – i.e., to make it easy for your content editor to edit those entries – by wrapping the titles in anchor tags and pulling the entries' cpEditUrl property:

if ($sponsorEntries = @$entry-&gt;$attribute-&gt;find())
{
    $tempArray = [];
    foreach ($sponsorEntries as $sponsorEntry)
    {
        $tempArray[] = '&lt;a href="' . $sponsorEntry-&gt;cpEditUrl . '"&gt;' . $sponsorEntry-&gt;title . '&lt;/a&gt;';
    }
    return implode(', ', $tempArray);
 }


...or if you prefer, you can make the links point to the entries on the frontend, by using $sponsorEntry-&gt;url instead:

$tempArray[] = '&lt;a href="' . $sponsorEntry-&gt;url . '" target="_blank"&gt;' . $sponsorEntry-&gt;title . '&lt;/a&gt;';