Hi,

Thanks for this great module.
I have used this module before but I did not encounter this issue as I am having a different set up now.

I have 4 languages in the system, DE/FR/IT/EN with EN being disabled. When creating a new translatable content (product) the language selector shows all 4 languages including EN which is disabled.

This allows users to create content in a disabled language even though they do not have the appropriate permission granted.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

msti created an issue. See original summary.

msti’s picture

Title: Lang selector when creating new content » Lang selector show disable lang when creating new content
nielsaers’s picture

I've been kinda busy lately, but i'm happy to review and accept a patch.

If I find some time i'll look into it.

brentg’s picture

Status: Active » Needs work
FileSize
1.43 KB

Worked a bit on this issue on drupaljam, but was not able to finish this.

In my opinion we'll need a custom permission for this, because in some cases the module can be used to disable a language where the content is being created, and in that case you'll need to be able to create content in a disabled language.

Done:
- Created custom permissions
- Started on writing a custom widget alter with permisson check

TODO:
- Disable the languages in the edit form.

Notes:
I tried with a form alter and field_widget_alter, but it seems that it's not a standard select list, but something special for the languages, so I don't know if you can easily remove items from the select list

sandboxpl’s picture

Version: 8.x-1.0-beta5 » 8.x-1.x-dev
Status: Needs work » Needs review
FileSize
1.72 KB

There is a way to alter language_select widget options, but as there's lot of processing going on, those options are available bit late,
dealing with it in #after_build callback does the job

michaelvanh’s picture

Hello sandboxpl i tested your patch in #5 and it seems to work well. Another thing to consider could be: When on a node edit form you click the 'translate' tab. All languages are still visible including the disabled ones, maybe these should be hidden? The 'add' link does redirect however.

bserem’s picture

Status: Needs review » Needs work

Patch #5 doesn't work for me. I see the permission, but the select widget continues to display all languages even for people without the permission.

UPDATE:
Patch #5 works for me on a new test environment a created locally.

bserem’s picture

Status: Needs work » Reviewed & tested by the community
bserem’s picture

sandboxpl’s picture

Issue tags: +Amsterdam2019
sandboxpl’s picture

@michaelvanh altering content translation tables is a tricky thing, I think it should be reviewed and executed in a separate issue, I've created new one for that: https://www.drupal.org/project/disable_language/issues/3091554

  • sandboxpl committed 0f9b623 on 8.x-1.x
    Issue #3032728 by sandboxpl, brentgees: Lang selector show disable lang...
sandboxpl’s picture

Status: Reviewed & tested by the community » Fixed

reviewed and committed do dev,
thanks for providing code and testing this one !

Status: Fixed » Closed (fixed)

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