Problem/Motivation
The user profile edit page, user/%uid/edit, has a field set for language settings and another one for locale settings. I don't think this is necessary and they should be joined together in one field set labeled 'Locale settings', because language and timezone are actually locale settings. So they should be joined in one field set to clean up the form a bit. This has been the case since Drupal 5.1, where at that time the system.module and locale.module each define their own field set on the user account settings page.
Proposed resolution
- Create one field set for locale settings.
- Locale setting also seems to be a really bad UX, Localization is a bit better at least and actually is more descriptive of what it does.
Remaining tasks
- Review
Usability review- Commit
- Enjoy!
User interface changes
Monolingual
Before:

After:

Multilingual
Before:

After:

API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #59 | afterpatch.png | 63.21 KB | rinku jacob 13 |
| #59 | beforepatch.png | 53.86 KB | rinku jacob 13 |
| #58 | interdiff-134209-55-57.txt | 2.48 KB | mohit_aghera |
| #58 | 134209-57.patch | 7.75 KB | mohit_aghera |
| #55 | interdiff-134209-52-55.txt | 1.3 KB | mohit_aghera |
Comments
Comment #1
yojoe commentedComment #2
dries commentedI like this change.
(It makes you wonder though -- should the per-user timezone settings live in locale.module? I don't think so, but it's probably good to raise the question as people might find that more intuitive ...)
Comment #3
drummFeatures such as this will not go into the stable Drupal 5.x.
The patch no longer applies.
Comment #4
yojoe commentedNow that Drupal 6 approaches, I want to raise the question again, if this should be fixed?
Comment #5
panchoDidn't apply anymore. Updated this patch to HEAD, although it's a bit late in D6 for this.
Comment #6
panchoOops, forgot to set to CNR...
Comment #7
panchoDries said:
This should be discussed further as soon as we're in the D7 dev cycle.
Joining the two fieldsets on the user page would anyway make sense. So if someone could test and rtbc this patch...?
Comment #8
dpearcefl commentedIs this is an active need?
Comment #10
Robin Millette commentedComment #11
johnennew commentedPlease find an updated patch attached for review.
In Drupal 8.x, language fieldset is provided by the user module and locale is provided by the system module. The user module comes first so I changed it's language fieldset to be called locale with a title of 'Localization'.
System module then uses this fieldset.
Comment #13
johnennew commentedI'll look at updating the tests.
On reflection, why does the system module add the timezone selector to the user edit form. Although system module provides the timezone api functions, it should be the user module which adds the options to the user edit form. Since user and system are both core required modules for all Drupal sites I see no issue in moving all the options to the user module.
Next patch will include this.
See attached screenshot of what the combined fieldset looks like.
Comment #14
johnennew commentedNew patch attached for review. The patch moves the form elements for timezone out of the system module and puts it in the user module. The user module language form elements are placed inside a localization fieldset with the timezone element. This also corrects the openid module tests.
Comment #15
berdirCan use $this->moduleHandler now. And should use Drupal::config().
Comment #16
berdir#14: language-timezone-one-user-field-134209-7255592.patch queued for re-testing.
Comment #18
berdirWow, this is old :)
I guess this won't get into 8.1 and definitely not 8.0. Still would like to get rid of all those system/user form alters and hooks. Also pulling in some changes from #2051067: Move user timezone code from system.module form alters to user form controllers.
Also not sure if we need to keep system_user_timezone() and @deprecate it. I guess so, technically although nobody is hopefully calling it.
No interdiff since most of it didn't apply anymore.
Comment #19
berdirActually, that extra fields change makes no sense, we need to rename the existing one and just drop timezone.
Comment #22
dawehnerWould this require a hook_update_N call? Can't you move around the extra fields?
Comment #23
berdirRenamed the key back to language, makes this a smaller API change, also fixes the installer config test.
Improved the migrate test to actually set a default timezone which is always there in a non-kernel test. somehow ended up with a NULL vs. '' difference.
Comment #33
quietone commentedRerolled so I could make a screenshot to compare with the related issue.
Comment #34
jibranI closed #272397: Update "Locale settings" on the user edit page to "Time zone settings" as a duplicate of this. This patch makes more than to me than the other issue. Let's ask for a usability review here.
Comment #35
aaronmchaleRegarding usability review: Could we get some details under the User Interface Changes section of the Issue Summary, specifically before and after screenshots, thanks.
Also, IS references Drupal 5, might want to update that as well ;)
Comment #36
jibranComment #37
quietone commentedComment #38
quietone commented@AaronMcHale, thank you for the instructions.
I've updated the IS and added screenshots. I am hoping this is ready for a usability review now.
Comment #39
quietone commentedMeant to set to NR.
Comment #40
berdirThis means that we also need to remove the timezone key in user_entity_extra_field_info() and update all user form displays to remove that key from it.
This will break some customizations I suppose, but we did that before, form structures are not part of BC. That said, this being a separate extra field is slightly more complicated, as it might result in the timezone field showing up for sites that had hidden it through the form display but have language visible. As there is still the user configurable flag, I suppose that is only a very small amount of sites, but who knows.
Leaving at needs review as we can work on that after we have a +1 from a usability perspective.
Comment #41
aaronmchaleFix some screenshot links.
Comment #42
benjifisherI am updating the issue summary, showing the screenshots instead of providing links.
Comment #43
benjifisherUsability review
We discussed this issue at #3200771: Drupal Usability Meeting 2021-03-05. In short, YES!
It is kind of silly to have three fieldsets or details elements (or even one or two) with just one form element each. While that will still be the case for monolingual sites (two fieldsets, each with one form element) this issue will improve the situation for multilingual sites.
We tried, but we could not think of any drawbacks.
Back to NW because of #40.
Comment #44
quietone commented@benjifisher and the UX team, thanks for the quick turnaround on this issue!
The next step is to do the work for #40.
This satisfies the first part, removing timezone fro user_entity_extra_field_info().
The second part is to update all user form displays to remove that key from it. How to do this? My knowledge of forms is pretty limited.
Comment #45
quietone commentedAdding Bug Smash tag because work on this started from the duplicate that was original a Bug Report.
Comment #46
mohit_aghera commentedI think we need to remove
languagekey from the entity_form display modes.@Berdir, I found two occurrences for the same and removed in current patch.
Please correct me if I am missing something.
Comment #47
guilhermevp commentedPatch works as intended, while addressing #40. Since the propose is already revised I'm moving it to RTBC.
Edit: forgot to post image evidence. Adding below.
Comment #48
guilhermevp commentedComment #49
catchThe second half of the issue title seems to be outdated, haven't reviewed the code properly yet but noticed no system.module changes.
Comment #50
catchWhy is this necessary? Presumably not due to the form changes?
Will this require any form displays to be updated that could be referencing the extra field?
This looks like it's probably OK but again why is it done in this issue? Doesn't seem necessary for changing the fieldset.
OK yeah this confirms the question above - so I think we probably need an update to remove timezone from every core.entity_form_display.user.user.*
Comment #51
berdirthis is likely a leftover from a reroll. Another issue moved this code from system.module to user.module and it added it to user_user_login(), so this would duplicate it.
And yeah, not sure about the migrate test changes.
Comment #52
mohit_aghera commented- Fixing suggestions #1 and #3
- For suggestion 2 and 4, I spotted two
core.entity_form_display.user.user.default.ymlfiles only.Both the files are updated in patch #46
Comment #53
berdirI think this part is also safe to remove. It doesn't make any functional changes, I was able to remove any changes to the test and it still passes, so I think we should remove these changes too.
Comment #54
mohit_aghera commentedComment #55
mohit_aghera commentedRemoving additional test cases.
@Berdir, do you think we should add functional tests? I think we are just changing form structure, so I thought of not to add.
Let me know if it makes sense.
Comment #56
berdirHm, good question, but functionally, the wrappers have no effect as they have no #tree TRUE. So we are testing that each element works, just not that it visually appears within a given details element. But we don't have that for any existing element either I think, so I'd say that's not a requirement?
What we still do need is an update function to clean out remaining configuration. A post update that loads each user form display and removes the timezone component. See https://api.drupal.org/api/drupal/core%21modules%21system%21system.post_... for some examples that do stuff with form displays in updates.
I just checked, and the filled database dump has the timezone field enabled, so we just need to assert in a test then that it is no longer there. To see that, add var_dump(\Drupal::config('core.entity_form_display.user.user.default')->get()); to the end of \Drupal\Tests\system\Functional\UpdateSystem\UpdatePathTestBaseFilledTest, and then alter it to assert that the timezone key is no longer in there.
Also created a change record: https://www.drupal.org/node/3209248
Comment #58
mohit_aghera commented@Berdir Implemented following changes:
- Added an update hook to remove timezone from the configuration
- An test case to test the update hook process.
Test cases are passing on local.
Comment #59
rinku jacob 13 commentedVerified and tested patch#58 on the drupal 9.3.x-dev version. Patch applied successfully and looks good to me.Adding screenshot for the reference.
Need +1 RTBC
Comment #60
longwave$form['timezone']no longer exists so this code needs updating or removing.The logic around whether the fieldset is displayed or not and which type it is seems quite convoluted, are we sure that it is displayed correctly for all possible configurations?
Comment #61
berdirWe did move the #access down. And the language field already depends on !$self_register.
But yes, we can remove that condition then.
Not 100% sure about about the new check vs. the explicit != TIMEZONE_SELECT check before. There is a third option, empty. I can actually not see any explicit usages of that, so not sure where that is used also confuses me as afaik we set a value then anyway in \user_user_presave. Anyway, I would propose to remove the if and keep the explicit == UserInterface::TIMEZONE_SELECT check then.