Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling relations #13

Open
thomasbnielsen opened this issue Nov 22, 2013 · 2 comments
Open

Handling relations #13

thomasbnielsen opened this issue Nov 22, 2013 · 2 comments

Comments

@thomasbnielsen
Copy link

Hi,

First of all, thanks for sharing this module :-)

I'm trying to get my ModelAdmin set up for the client to handle 2 languages.
I have a Vessel dataobject that i have extended with Vessel::add_extension('TranslatableDataObject');
I'm able to get my textfields added for translations.

On my dataobject Vessel i have:
static $belongs_many_many = array( 'Groups' => 'VesselGroup' );

The question is: How do i handle the relation? I need to add groups to each Vessel, and the groups are a Page in either English for the default language and danish for the secondary.

I can allready manage the groups if i set the language of the ModelAdmin manually by entering ?locale=da_DK in the URL.

Should i choose to use $fields->add($this->getTranslatableTabSet()); and if so, how do i manage the groups?

Or should i do it the same way as pages, where you change the language in the backend? For this option - how do i get some kind of button or dropdown in the ModelAdmin that allows the client to change the locale? (Asking them to type in the URL each time is not an option :-))

Hope you can help

@bummzack
Copy link
Owner

Not sure if I understand your goal correctly. So you already can enter the translations in ModelAdmin, but not the relations? Did you see this: #12 ?

Wouldn't it be possible to be the other way round, so that you add the Vessels within the Group-Page?

@thomasbnielsen
Copy link
Author

Thanks for linking issue 12, it's kinda the same.
Yes i can turn it around and add the relation in the group page, but that kinda defeats the purpose of the ModelAdmin (i think).

Let me try to explain the problem again: I like the idea of the $fields->add($this->getTranslatableTabSet()); - this allows the client to edit both the Danish and English language in the modeladmin - no need to jump into pages, changing language and so on.

But i have a relation, each of my Vessels belongs to many groups: static $belongs_many_many = array( 'Groups' => 'VesselGroup' ); VesselGroup is a PageType.
I would like to be able to set the different groups that a Vessel belongs to in ModelAdmin (again, the client should not need to leave ModelAdmin) but since we are not changing the language, i only get the options for the Group pages of the current language.

I'm getting the groups by doing this:
$Groups = DataObject::get('VesselGroup')->sort(array('ParentID' => 'ASC','Title'=>'ASC'));
$fields->addFieldToTab("Root.Groups", new CheckboxsetField('Groups', 'Grupper', $Groups->map('ID', 'CheckboxSummary')));

I think the best solution would be to add an option to change the language in the modeladmin - as sugested in #12.
and then not use getTranslatableTabSet, but implement the getCMSFields method manually.

Sorry for the bad explanations, but i hope you can follow me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants