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

Inputfields with setting "useLanguages=false" are not usable #1787

Closed
BernhardBaumrock opened this issue Jul 21, 2023 · 2 comments
Closed

Inputfields with setting "useLanguages=false" are not usable #1787

BernhardBaumrock opened this issue Jul 21, 2023 · 2 comments

Comments

@BernhardBaumrock
Copy link

BernhardBaumrock commented Jul 21, 2023

Short description of the issue

This might be related to this issue: #1118

I've encountered problems on a site where I wanted to have a single-language title field on a multi-language template. The reason for this is that the page itself has multilang content but the title is really always only a single language. To make it less abstract: It's my personal website where I want to showcase my modules. So the description is in DE/EN but the title of the page is always single language, like RockPageBuilder or RockMigrations etc...

I've used Robin's solution mentioned in this thread: https://processwire.com/talk/topic/24431-how-to-disable-multi-language-page-title-for-one-template/?do=findComment&comment=206825

Today I realised that my page names are not auto-updating on page save, which should be done via a RockMigrations helper that I'm using all over for a long time.

I found out that the issue comes from the title field. The problem is that it has still a multi-lang value in the API but it only has a single-lang UI in the backend:

While I totally understand that from a technical point of view it makes the field useless for the real world.

Actual behavior

The problem is that if a user with lang EN inputs foo the field will show foo for him. But if another user with lang DE edits that page he/she will see value bar that has been input sometime in the past. Now if that DE user changes the field to baz we will have inconsistent values:

EN = foo
DE = baz

Steps to reproduce the issue

  1. On a multilang site and template add the hook to set the title field to useLanguages = false
  2. Make sure your user is using the default language
  3. Enter DEFAULT into the title field and save
  4. Change the user's language to non-default
  5. Enter NON-DEFAULT into the title field and save
  6. Now switch languages in your user's profile and reload the page edit screen - you will see the value of the title field will change from DEFAULT to NON-DEFAULT and vice versa

Possible Solution

I'm not really sure what to do about that and wether that is an issue or not. Technically it might not be an issue, but it would be nice to have a simple solution to just make some fields on a multi-language page single language only. And there - of course - they should always have the same value no matter what language the editor has set in his/her profile.

Setup/Environment

ProcessWire: 3.0.222
PHP: 8.1.16

@ryancramerdesign
Copy link
Member

@BernhardBaumrock

The problem is that it has still a multi-lang value in the API but it only has a single-lang UI in the backend:

That's because the field itself is multi-language (via its Fieldtype[Name]Language module), but if you've set $inputfield->useLanguages=false; then multi-language features are disabled for the Inputfield. That's going to create an issue because you've then got a multi-language field with a single-language input. When the $page->title is set to the Inputfield's value attribute, it will be in the user's language, since the string value of a LanguagesPageFieldValue is the value in the user's language.

That useLanguages property is what LanguageSupportFields module uses to enable multi-language on an Inputfield via its own hooks, so you are competing with it by manually changing it with your own hook. I think that's also where a potential solution would be, in the hook you are using. Though to keep it simple, I would probably avoid trying to make a multi-language field behave as non-multi-language and instead use a different single-language field for this purpose. But if you need to use a hook, can you paste in your current hook? Maybe I can suggest things that might enable it to work.

@BernhardBaumrock
Copy link
Author

Hey @ryancramerdesign thx for the input! Sounds like it might really be the best to add a single language field in that case :)

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

No branches or pull requests

3 participants