3

I've created my first new ElementType based on the Events example. 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?

4

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');
}
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.