Problem/Motivation

If you use field groups in node edit form and use "Details Sidebar" group then group is not visible on node translation page. Also the fields under that group are gone.

Node add translation

Manage form display

Steps to reproduce

  1. https://simplytest.me/
  2. Start with Field Group 3.1
  3. Add new field group to Article at /structure/types/manage/article/form-display
  4. Choose "Details Sidebar"
  5. Save and add some fields under the new group
  6. Create new node and test that it works
  7. Install "Language" and "Content Translation" modules
  8. Add some new language to site /admin/config/regional/language
  9. Enable translations on Article /admin/structure/types/manage/article
  10. Add new role eg Editor /admin/people/roles
  11. Add permissions to new role /admin/people/permissions:
    • Create translations
    • Translate Article content item
    • Article: Create new content
    • View the administration theme
  12. Add new user /admin/people and add Editor role
  13. Log in with the new user and create node (check that the group exists)
  14. Now add new translation /node/2/translations
  15. That group is not visible and the fields in it are gone. In my case it was title field but it's any field you add under group.
  16. There are some group types that work: Details, Tab and Tabs. Rest of them behave the same - they are gone.

Simplytest runs on Drupal 8.9.16

Locally I also tested this on dev branch.

Proposed resolution

The group and fields should be visible.

Comments

hkirsman created an issue. See original summary.

hkirsman’s picture

Issue summary: View changes
StatusFileSize
new55.43 KB
new106.94 KB
hkirsman’s picture

Issue summary: View changes
hkirsman’s picture

Component: Miscellaneous » Code
hkirsman’s picture

Priority: Normal » Critical
hkirsman’s picture

Priority: Critical » Major
swentel’s picture

Just to be sure, is it visible as user 1 ? It is for me here, just want to be able to rule that out.

hkirsman’s picture

It is yes.

swentel’s picture

Interesting, I can reproduce, checking for patch.

swentel’s picture

The thing is that I don't even see a sidebar when fieldgroup is disabled too, so core hides/ignores some detail elements if you don't have many permissions when creating a translation, not sure why or what the logic is at the moment. But it isn't necessarily a field group problem at the moment. Will check whether I can still come up with a fix though.

hkirsman’s picture

Thanks for investigating!

By default user can't translate node. You'd need to specifically add permissions like:
- Create translations
- Translate Article content item

Then the button appears. Don't know what else to add.

swentel’s picture

Yes, I've added those permissions. I can access the translate screen, so that's ok.

It's ContentTranslationHandler::entityFormSharedElements that starts hiding elements - based on translation status and permissions. Will be tricky to get around that.

swentel’s picture

Priority: Major » Normal
StatusFileSize
new1.3 KB

So it really is a core thing, but I can get around it. Patch isn't completely right though, but it's getting close.

hkirsman’s picture

Seems to be working already! What's missing?

swentel’s picture

Well, there should be an extra condition to check if we're on the 'add translation' route. I would also add an another condition which defaults to FALSE to expose this behavior because otherwise it might 'break' a lot of existing sites out there where suddenly the sidebar starts popping up. So something like this:


if ($is_add_translation_route && Settings::get('field_group_show_sidebar_on_translation_route', FALSE)) {
  // Rest of logic
}
hkirsman’s picture

StatusFileSize
new1.54 KB
new1.41 KB

I've added the translation route check plus isset() function to check if $element['advanced']['#access'] exists before checking if it's FALSE. Got warnings in some cases when it did not exist. Tested on my setup and seems to work fine.

hkirsman’s picture

I also found this issue but don't think it's there anymore https://www.drupal.org/project/drupal/issues/3097407 ? Or actually maybe it is as it's about Claro theme.

swentel’s picture

Status: Active » Reviewed & tested by the community

Ok, looks good to me. I'll leave it to zuuperman to have a second check before committing :)

  • nils.destoop committed dbdf8ba on 8.x-3.x authored by hkirsman
    Issue #3222507 by hkirsman, swentel: Field groups are missing in node...
nils.destoop’s picture

Status: Reviewed & tested by the community » Fixed

I tested the patch, and everything seems to be ok. Committed it to dev

vaidas_a’s picture

Guys, thank you for the patch, it solved the issue when adding a new translation.
Would be great if we have the same behaviour also when editing an existing translation too (route name 'entity.node.content_translation_edit')

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

swirt’s picture

Hi. I know this issue is closed and outdated. I opened a new one, however I wanted to call this out here so it is in context.

// Move our hook_form_alter() implementation to the end of the list.

This was very heavy handed and broke code that we needed to run after this form_alter. We had it called out with module dependencies and explicitly setting the weight. This change completely took away our ability to control when our code ran.