<p>It will take two hooks in the <code>MyCustomPlugin.php</code> file to display data from the custom field. </p>

<pre><code>public function modifyEntryTableAttributes(&amp;$attributes, $source)
{
    if ($source == '*')
    {
        unset($attributes['expiryDate']);
        $attributes['whatever-you-want'] = Craft::t('Desired Table Heading');
    }
}
</code></pre>

<p>The <code>modifyEntryTableAttributes()</code> hook will allow us to add/remove columns from the Entries Listing table. Note that the <code>$attributes[]</code> variable will automatically try to match up whatever you put in there with an attribute on the entries. </p>

<p>This is probably all you need to drop a standard custom field into the table. However, since my custom field is an array, holding multiple bits of data, we need to use the <code>getEntryTableAttributes()</code> hook to dig in to my custom field and grab the item we want to display.</p>

<pre><code>public function getEntryTableAttributeHtml(EntryModel $entry, $attribute)
{
    if ($attribute == 'whatever-you-want')
    {
        // Assign my custom field to a variable
        $fieldData = $entry-&gt;mycustomfield;

        // Check if there is any data in the variable
        if (!empty($fieldData)) {

            // If so, return the specific key AS A STRING to the table
            return $fieldData['myCustomDate']-&gt;format('n/j/y');
        }

        return '';
    }
}
</code></pre>

<p>Notice the <code>return '';</code> at the end? That's important, because if an entry DOESN'T have my custom field attached to it, it will try to look up the <code>$attribute['whatever-you-want']</code> assuming that's a legitimate DB column, and will fail. </p>

CC BY-SA 3.0
2015-05-21T11:44:07.023Z
There is another great explanation of this here: http://craftcms.stackexchange.com/questions/9816/adding-additional-attributes-to-modifyentrytableattributes/9817?noredirect=1#comment12849_9817
Jesse Schutt
CC BY-SA 3.0
2015-05-20T19:56:28.790Z
2015-05-20T19:56:28.790Z
Jesse Schutt
<p>I've built a custom field that stores its data in its own table. How can I get data from MyCustomField to show up as a column in the Entries Table? </p>

<p>A few details:</p>

<ul>
<li>My custom field is made up of multiple fields, in this case a Date/Time field and a text field.</li>
<li>My custom field is is returned as an array by the <code>prepValue()</code> function in my fieldtype file.</li>
<li>Not every entry will have a record in my custom field's table</li>
</ul>

<p>How can I check to see if a value exists in my custom field's table for an entry and display it in the Entries Table?</p>

<p><em>I'm copying this over from the Craft Slack channel so we don't lose the solution.</em></p>

<plugin-development>
How can I add data from my custom plugin to the Entry Listing table?
# How can I add data from my custom plugin to the Entry Listing table?

(Asked by: username_0 on 2015-05-20)

I've built a custom field that stores its data in its own table. How can I get data from MyCustomField to show up as a column in the Entries Table?

A few details:

* My custom field is made up of multiple fields, in this case a Date/Time field and a text field.
* My custom field is is returned as an array by the `prepValue()` function in my fieldtype file.
* Not every entry will have a record in my custom field's table

How can I check to see if a value exists in my custom field's table for an entry and display it in the Entries Table?

*I'm copying this over from the Craft Slack channel so we don't lose the solution.*

**Tags:** plugin-development

---

## 1 answers

### Answer by username_0 on 2015-05-20. Score: 4 | Accepted answer

It will take two hooks in the MyCustomPlugin.php file to display data from the custom field. 
public function modifyEntryTableAttributes(&$attributes, $source)
{
    if ($source == '*')
    {
        unset($attributes['expiryDate']);
        $attributes['whatever-you-want'] = Craft::t('Desired Table Heading');
    }
}

The modifyEntryTableAttributes() hook will allow us to add/remove columns from the Entries Listing table. Note that the $attributes[] variable will automatically try to match up whatever you put in there with an attribute on the entries. 
This is probably all you need to drop a standard custom field into the table. However, since my custom field is an array, holding multiple bits of data, we need to use the getEntryTableAttributes() hook to dig in to my custom field and grab the item we want to display.
public function getEntryTableAttributeHtml(EntryModel $entry, $attribute)
{
    if ($attribute == 'whatever-you-want')
    {
        // Assign my custom field to a variable
        $fieldData = $entry->mycustomfield;

        // Check if there is any data in the variable
        if (!empty($fieldData)) {

            // If so, return the specific key AS A STRING to the table
            return $fieldData['myCustomDate']->format('n/j/y');
        }

        return '';
    }
}

Notice the return ''; at the end? That's important, because if an entry DOESN'T have my custom field attached to it, it will try to look up the $attribute['whatever-you-want'] assuming that's a legitimate DB column, and will fail.

> **Comments:**
> **username_0**: There is another great explanation of this here: http://craftcms.stackexchange.com/questions/9816/adding-additional-attributes-to-modifyentrytableattributes/9817?noredirect=1#comment12849_9817  

---

