Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm updating my module user-tabs, which puts the edit tab and other user_categories underneath the default user view tab, thus making room for other modules to add user tabs.
However I can't find any equivalent of user_categories in d8.
Can I be pointed in the right direction?
Comments
Comment #1
matslats CreditAttribution: matslats as a volunteer commentedI have worked out a cumbersome way to do what hook_user_categories did, i.e. divide the user profile into several pages (at least for editing).
1. Create a new form_modes on the user entity /admin/structure/display-modes/form/add/user
2. Edit the field visible in each form mode /admin/config/people/accounts/form-display
3. implement hook_entity_type_alter thus:
$entity_types['user']->setFormClass('CATEGORY', "Drupal\user\ProfileForm");
4. Declare new routes in mymod.routing.yml thus:
5. Declare tabs for the above routes.
This procedure should be officially, documented. Further, since user_categories seems to be deprecated and this method rather different, I suggest the above be added to core, with the entity altering and menu items (and tasks) being created automatically optionally when the form mode is created. This would leave the user only to customise which fields go in which tabs.
The alternative I think would involve something like the content_profile module or maybe page_manager? Both of these would be overkill
Another helpful innovation would be to incorporate the usertabs module into this OR upgrade that module to offer this functionality. It puts the addition user_category edit tabs UNDER user/x/edit
Comment #2
cilefen CreditAttribution: cilefen commentedThis is the change record mentioning the removal: https://www.drupal.org/node/1393236
Comment #3
matslats CreditAttribution: matslats as a volunteer commentedWell done for digging up that reference.
More information about why it was removed and what might replace it would be useful too.
Comment #4
matslats CreditAttribution: matslats as a volunteer commentedThe replacement is quite great.
Just as each bundle has view modes it now has form modes
Each mode can have a different range of fields display.
It could be a bit easier I think - I still had to manually create the route and tell the entity there is a new form.
Then created a new route for it in MY_MODULE.routing.yml
Comment #13
quietone CreditAttribution: quietone as a volunteer commentedThe Change record pointed to by cilefen in #2 explains the change and matslats is using that information successfully.
Changing to a support request because the feature is still there just need to know where to find it. And closing as fixed.
Thanks!