Answers.Body: <p>To make it possible to select fields from a custom FieldType in the Customizable Element Indexes interface, your FieldType class needs to implement the <a href="https://craftcms.com/classreference/fieldtypes/IPreviewableFieldType" rel="nofollow"><code>IPreviewableFieldType</code></a> interface, like this:</p>
  
  <pre><code>class ExamplePluginHandleFieldType extends BaseFieldType implements IPreviewableFieldType
  {
      ...
  </code></pre>
  
  <p>If you want to modify how the values from your custom FieldType displays in element indexes, you need to add a <code>getTableAttributeHtml</code> method to your FieldType class:</p>
  
  <pre><code>public function getTableAttributeHtml($value)
  {
      return $value ? $value-&gt;id : null;
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-21T07:59:16.280Z
Answers.LastActivityDate: 2016-09-21T07:59:16.280Z
Answers.UserDisplayName: Mats Mikkel Rummelhoff
Body: <p>I've built a custom FieldType, and I'd like editors to be able to add any fields using this FieldType to element indexes. Unfortunately, fields using my custom FieldType aren't included in the list of fields in the Customizable Element Index configurator.</p>
  
  <p>How can I make it possible to add fields using my custom FieldType to element indexes?</p>
  
  <p>Also, is it possible to define how the value returned from my custom FieldType displays in the element index?</p>
  
Tags: <plugin-development><fieldtypes><custom-fieldtype>
Title: How can I make my custom FieldType show up in an element index?
ThreadText: # How can I make my custom FieldType show up in an element index?
  
  (Asked by: username_0 on 2016-09-21)
  
  I've built a custom FieldType, and I'd like editors to be able to add any fields using this FieldType to element indexes. Unfortunately, fields using my custom FieldType aren't included in the list of fields in the Customizable Element Index configurator.
  
  How can I make it possible to add fields using my custom FieldType to element indexes?
  
  Also, is it possible to define how the value returned from my custom FieldType displays in the element index?
  
  **Tags:** plugin-development, fieldtypes, custom-fieldtype
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2016-09-21. Score: 3 | Accepted answer
  
  To make it possible to select fields from a custom FieldType in the Customizable Element Indexes interface, your FieldType class needs to implement the [`IPreviewableFieldType`](https://craftcms.com/classreference/fieldtypes/IPreviewableFieldType) interface, like this:
  
  ```
  class ExamplePluginHandleFieldType extends BaseFieldType implements IPreviewableFieldType
  {
      ...
  
  ```
  
  If you want to modify how the values from your custom FieldType displays in element indexes, you need to add a `getTableAttributeHtml` method to your FieldType class:
  
  ```
  public function getTableAttributeHtml($value)
  {
      return $value ? $value->id : null;
  }
  
  ```
  
  
  ---
  
  