Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

ModelAdmin Search Filter for field with many-many relationship


Go to End


3 Posts   2260 Views

Avatar
tantivy

Community Member, 1 Post

11 June 2015 at 10:27am

I'm using getDefaultSearchContext() to customise the search filters appearing in the ModelAdmin grid view. It works fine for one-to-many relationships, with ExactMatchFilter, but breaks on a many-to-many relationship.

I'm using a ListboxField so that the query generated by ExactMatchFilter is of the form "where q[fieldName] in (1, 2, 3)", but it would need to generate a more complex query than that, which I don't see any signs of in ExactMatchFilter or the other search filter subclasses.

Has anyone else solved this problem? Maybe there's a search filter subclass or an extension that can do it?

Avatar
Andrew Houle

Community Member, 140 Posts

14 January 2016 at 4:18am

I've also ran into this... Anyone have a working solution for this?

Avatar
swaiba

Forum Moderator, 1899 Posts

15 January 2016 at 1:24am