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.

All other Modules /

Discuss all other Modules here.

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

Translatable: Locale GridFieldConfig_RelationEditor


Go to End


3 Posts   902 Views

Avatar
geekdenz

Community Member, 37 Posts

12 August 2014 at 8:15pm

Hi,

I would like to create a GridField with GridFieldConfig_RelationEditor as its config. However, I am also using Translatable to have Locales on DataObjects, namely Page extending Page Types. I have translations of pages and when I have a relationship editor it also shows the other languages' pages in the autocomplete. I would like to filter and only have the English pages display in English and the other ones in their respective locales. However, I was unable to find a solution already in the forums.

Here some example code:
http://www.sspaste.com/paste/show/53e9c8c2b586f

Avatar
geekdenz

Community Member, 37 Posts

12 August 2014 at 9:33pm

I figured out a solution. Maybe not perfect, but it works and is not too ugly:
http://www.sspaste.com/paste/show/53e9dae1e1bf3

Avatar
flx

Community Member, 1 Post

16 October 2014 at 11:55pm

hi
I found a smoother solution:
attach a filtered SS_List to the Completer that includes only Pages in current Locale, inside getCMSFields:

$config = GridFieldConfig_RelationEditor::create();
if(Translatable::locale_filter_enabled())
  $config->getComponentByType('GridFieldAddExistingAutocompleter')->setSearchList(Page::get()->filter('Locale',$this->Locale));