Problem/Motivation
When creating a group, the title of the page is "Add group", regardless of what type of group you are adding.
The node module displays "Create @name" (where @name is the bundle label). It does so by adding a _title_callback for the node.add route (defined in core/modules/node/node.routing.yml); which it sets to \Drupal\node\Controller\NodeController::addPageTitle, which looks like:
public function addPageTitle(NodeTypeInterface $node_type) {
return $this->t('Create @name', ['@name' => $node_type->label()]);
}
Steps to reproduce
- Set up a new Drupal 8.5 site using the standard install profile.
- Clone the group module (I'm at commit
674ba8a, the HEAD of 8.x-1.x at the time of writing) - Enable the group module
- Create one group type from
/admin/group/types/add. I made a type with the name "Lorem" - Try to add a group of that type from
/group/add.- Expected behavior: the page title says "Add Lorem"
- Actual behavior: the page title says "Add group"
Proposed resolution
Do the same thing that the Node module does. That is to say:
- Add a
\Drupal\group\Entity\Controller\GroupController::addPageTitle - Set the route to reference it via a _title_callback
Note that, unlike the Node module, the route is defined in \Drupal\group\Entity\Routing\GroupRouteProvider::getAddFormRoute so we'll have to add the _title_callback in there.
Remaining tasks
Write a patchReview and feedbackRTBC and feedbackCommit
User interface changes
When adding a new group, the bundle label is displayed as the title of the group/add form.
API changes
None.
Data model changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 2989280-3-display-add-bundle-label.patch | 1.76 KB | mparker17 |
Comments
Comment #2
mparker17After a bit of investigation, this only happens if you have one group type: updated issue title and summary.
Also, uploaded some screenshots comparing the behavior when there is one group type vs two group types.
I also uploaded a screenshot showing what the Node module does when there's only one node type for comparison (and as an example of the desired behavior).
Comment #3
mparker17Here's a patch that fixes the issue; and a screenshot showing the change.
Comment #5
mparker17With an error like:
... I think Testbot is having a bad day?
Comment #6
lolcode commentedThis worked for me and the code looks fine as far as I can tell.
Comment #7
kristiaanvandeneyndeIt overwrites this part of EntityController:
But given how group doesn't ship with default group types... sure, why the hell not.
Comment #9
kristiaanvandeneyndeComment #10
mparker17Awesome, thanks!