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.

Customising the CMS

ModelAdmin Gridfield autocomplete filtering


Reply

2 Posts   451 Views

Avatar
johannes

23 April 2013 at 12:03am Community Member, 20 Posts

I'm building a multi language site with the Sapphire framework and I'm trying not to bother the editors with content from others languages. Now I came across a little problem:

What I have:
Articles which have many tags (many_many) and the tags belong to many articles (belongs_many_many).
Also each tag has a language property.

My Problem:
In the ModelAdmins Gridfield autocomplete all tags are listed, also from other languages. The canView function seems to be ignored here.

Is there a way to show only elements matching the Members locale?

Avatar
johannes

23 April 2013 at 3:38am (Last edited: 23 April 2013 3:38am), Community Member, 20 Posts

Solved it for now, but I'm not really happy because I had to edit a core file.
I altered the doSearch function in the class GridFieldAddExisitngAutocomplete.php on line 207 :

foreach($results as $result) {
if ( ! $result->canView()) continue;
$json[$result->ID] = SSViewer::fromString($this->resultsFormat)->process($result);
}

I hope to find another (update-safe) method to filter the results.