<p>In case anyone else comes up against this, here's what I did to fix it.</p>

<p>In my <code>PluginName_MyElementType</code> class which inherits from <code>BaseElementType</code>, you need to override the <a href="http://buildwithcraft.com/classreference/elementtypes/BaseElementType#defineSearchableAttributes-detail" rel="nofollow"><code>defineSearchableAttributes</code></a> method, returning an array containing all the names of the properties of your <code>Model</code> which need to be searchable. So in my case it's just <code>name</code>. The reason you don't need to worry about adding <code>title</code> is it's already done for you under the hood, it's just that I wasn't using it in this case. </p>

<pre><code>public function defineSearchableAttributes()
{
     return array('name');
}
</code></pre>

CC BY-SA 3.0
2015-06-16T09:05:41.180Z
2015-06-16T09:05:41.180Z
Steve Holland
<p>I've created my first new <a href="http://buildwithcraft.com/docs/plugins/working-with-elements" rel="nofollow">ElementType</a> based on the <a href="https://github.com/pixelandtonic/Events" rel="nofollow">Events example</a>. The only thing which doesn't seem to be working is the search bar above the listing in the CP. When I type anything into it I just get a blank results returned.</p>

<p>I think it's something to do with me not using <code>Titles</code>, I'm using a property on the Model called <code>name</code> instead. I had to override the <code>__toString</code> method in the model to get it to populate the first column in the listing, so I'm guessing there is some way to also overriding what is used by default for the search as well. Is that the case, and if so how do it do it? </p>

<plugin-development><elementtype>
Filtering list in CP index page for new ElementType
# Filtering list in CP index page for new ElementType

(Asked by: username_0 on 2015-06-11)

I've created my first new [ElementType](http://buildwithcraft.com/docs/plugins/working-with-elements) based on the [Events example](https://github.com/pixelandtonic/Events). The only thing which doesn't seem to be working is the search bar above the listing in the CP. When I type anything into it I just get a blank results returned.

I think it's something to do with me not using `Titles`, I'm using a property on the Model called `name` instead. I had to override the `__toString` method in the model to get it to populate the first column in the listing, so I'm guessing there is some way to also overriding what is used by default for the search as well. Is that the case, and if so how do it do it?

**Tags:** plugin-development, elementtype


---

## 1 answers

### Answer by username_0 on 2015-06-16. Score: 4 | Accepted answer

In case anyone else comes up against this, here's what I did to fix it.
In my PluginName_MyElementType class which inherits from BaseElementType, you need to override the defineSearchableAttributes method, returning an array containing all the names of the properties of your Model which need to be searchable. So in my case it's just name. The reason you don't need to worry about adding title is it's already done for you under the hood, it's just that I wasn't using it in this case. 
public function defineSearchableAttributes()
{
     return array('name');
}


---

