Problem/Motivation
Currently the only way to relate content entities like users and nodes is from the group admin content page, but sometimes you would like to have a multiple groups admin user able to relate content with multiple groups at the same time.
It'd also be nice to be able to display all the groups that a given piece of content is associated with.
Proposed resolution
Provide a computed field ready to be used on all the content entity types supported by the GroupContentEnabler Plugin, out of the box the group module provides support for users and nodes (gnode submodule).
https://www.drupal.org/project/entitygroupfield provides this field which respects the groups permissions.
Remaining tasks
Immediate
- #3151914: Rename module and all its code to 'entitygroupfield'
- #3151916: Move changes from outside modules/gcontent_field into entitygroupfield
- #3151915: Migration path from gcontent_field to entitygroupfield
Next phase
Go through remaining tasks and #210 and split off child issues in the new queue, then update the summary to cross off that item with a [#x] link to the new issue.
#85 / #109fixed in #176 or before#177.2a#3152725: Don't lock the group select widget on node/add forms#90.4aFixed in #91.#90.8: Users should only see the parts of the widget that they can use.#3152723: Hide aspects of the widgets that a user doesn't have permission to use#90.9 (see also #117 and #147)Fixed in #160.#90.10: Needs tests#3152293: [META] Add test coverage for Entity Group Field#113#127 and #128Fixed in #155.#146Fixed in #158#149 (all)Fixed in #152.#150, #159: Tokens don't work.Fixed in #180.#162: gcontent-field.admin.css shouldn't useFixed in #180..jsselectors#164 and #166.a: The new widget and formatter(s) shouldn't be available on regular entity_reference fields.Fixed in #176#183: Add docs.#3152713: Add documentation for Entity Group Field#187: Allow this to not be read-only?#3152714: Consider if this field can be set as not read-only#190.2: Permission problems for 'Advanced Outsider Permissions' users.#3152715: Permission problems for 'Advanced Outsider Permissions' users#191: Uninstall breaks field configs#3152716: Uninstall breaks field configs#194: Namespace collision with "group_content" field_group#3152717: Rename field ID from "group_content" to "entitygroupfield"#195: Cardinality bugs with widget#3152719: Group cardinality bugs with widget#196.1: Widget should render as a details container ("fieldset")#3152720: Widget should render as a details container#196.2: Why is the widget using tabledrag?#3152722: Widget should not use tabledrag#210#3152724: Improve architecture per kristiaanvandeneynde
User interface changes
- New field called "Group Content" available in all content entities supported for group via GroupContentEnabler plugin.
- New widget called "Group selector" which provide a good UX for editing the relations with groups. Makes it possible to alter the group content fields especially useful for user roles in groups.
- New formatters:
- "Parent group rendered entity": allows you to show the rendered group entity (with an option to control the view_mode to use).
- "Parent group ID": allows you to show the group entity ID.
- "Parent group label": allows you to show the group entity label (with an option to make the label a link to the group or not).
Data model changes
None (really). There's a new field, but it just gets stored in the default Drupal Way(tm).
Original report by @jazzfiction
There are times where I would like to add a group relationship to content from outside of Groups itself. Examples would be adding a large amount of content inside the Content area for various groups, to making rules where if a taxonomy term is applied to a piece of content, then the rule would relate that content to a group.
As of right now, I haven't found a way to do that. I have tried adding entity reference fields to content types, trying to have rules automatically assign content group relations when certain condition arise, to trying to create a page like the add content page where all of the references are listed, and I can then add or delete them.
All I am trying to do is not have to go through various groups to try to modify a relationship when I want edit it as there will be eventually be many groups in my site. It may be that I am missing the obvious, as I am fairly new to modern versions of Drupal, as the last version I really used is D5. If this can be added to Groups, that would be great, or if this feature already exists, can somebody point me in the right direction?
Comments
Comment #2
flodevelop commentedMaybe you could use basic relationship between content and group without activate the gnode submodule.
Then the groups is like a taxonomy. But if you do that, you don't have group content so i think you can't manage the group permissions and roles on this group type and other great features.
Or you can code a custom module that check your fields values when insert or update the node content so you can manage the relationship (group content) between your content and the goup.
For example, you can add a user to a group, it is the same process for the content i think :
Comment #3
jidrone commentedHi Everyone,
I create a patch with a group submodule which provide this functionality, I already tested it in nodes and users.
The submodule requires Inline Entity Form, once enabled you should see a fieldset called "Group Options" in the entity form and it also respect the groups permissions.
Comment #4
anairamzapHi,
I've tried the patch in #3 and its adding the expected functionality.
Steps I've followed:
1. Apply patch
2. Enable group, gnode, and the new submodule "gcontent" provided by patch (please note that new submodule has a dependency on inline_entity_form so you will need that module too).
Once the Content and User plugins are enabled for the group type, you I get a new "Group Options" fieldset on the Node add/edit and User add/edit forms. For the User form it correctly adds the new/existing user to the group. For the node add/edit it correclty assigns the node as a Group Content.
Also, If you have fields on the group type > content/user, these fields will be displayed inside the Group Name fieldset.
@jidrone Iván, one tiny thing I've noted is that if you don't have any fields set on the group available content config, you still get the Group Name fieldset but when you expand it is empty. Maybe we can display a message saying something like "This bundle doesn't have any configurable fields".
Comment #5
zenimagine commentedThank you for this patch that will greatly simplify the group for my users.
I will test it and I will make a return.
There is the OpenSocial distribution for Drupal 8 which has perfectly integrated this functionality. You can test on this demo site:
https://www.drupal.org/project/social
https://demo.getopensocial.com/
Here is the custom module they created, I did not test it (do not install it in production) :
"zip"
Comment #6
zenimagine commented@jidrone I just tested the sub module and it works well.
But there is some missing parameter that is not configurable:
- On my site the group must be required.
- On my site, the content can only be assigned to one group. So you need a selection list instead of autocomplete.
- This relationship with the group must be a field, to customize its position in the node edit form and render in twig.
- The relationship feature should be disabled in the group tab. Currently a user can add nodes in he is not the author to his group and this is a big problem.
See the comment #5
Comment #7
scotwith1t@zenimagine i had a few of the same concerns and @jidrone is I believe refactoring to make this be a true field so you can configure things like Required, move the field around in the UI, perhaps even change the widget. I like auto-complete as the default since a site with lots of groups being all crammed into one select list can cause problems, but having it be configurable would be another benefit of this being a field.
Comment #8
zenimagine commented@scotself the example module for open social displays the field with a selection list. This limits the content to a single group.
One could also mention Drupal Commerce with products that contain a store field. It can be configured in autocompletion or selection.
This is very good news if another patch is in development. I can not wait to test it.
Are you planning to disable the relationship tab and link links in groups? There should be the link add nicely.
Comment #9
dalra commentedA better way would be to solve things separately and create new permissions as requested in #2771065: Group Node: Only authors should be able to create Gnodes for their nodes:
- Add own existing content
- Add any existing content
Comment #10
jidrone commentedHi Everyone,
Yes, I'm developing another patch, the following are the improvements and reasons behind each:
Extrafield instead of Field type:
To allow admins to customize its position in the entity edit form, I will provide it as an extra field which will only appear on "manage form display" tab, I prefer that instead of the creation of a new field type because I think it's an overhead to have schema, storage and display functionality we won't use.
Configurable settings by Content Plugin:
Currently the group module has this form "admin/group/settings", which only have the option "Use admin theme". I will use this form to add some configurations for the field like: required, allow multiple, widget: select or autocomplete.
Permission to access to the field:
I'm adding a permission to access to the field, especially useful if you want to avoid anonymous user to see it in registration form.
I agree with @dalra to manage all the access related things with permissions, because this patch takes care of groups permissions.
Comment #11
zenimagine commented@jidrone It's awesome.
Can the field appear in the display ?
In the twig of my nodes, I want to display a link or rendered entity to the parent group.
Comment #12
zenimagine commentedHere is an example :
- In the screenshot of my product, I added above the dotted line the parent store. Drupal Commerce adds a field in the display of my product.
- In the screenshot of my article, I added the parent group above the dashed line. But I have to use views and EVA to get that (it's complicated). Adding a group field to the node view will be much simpler.
Comment #13
zenimagine commentedComment #14
jidrone commentedHi @zenimagine,
I was thinking about your last request, in case we need to provide a display for the field is best to create a field type to have formatter settings to choose a view mode for the group.
So the following could be a possible approach:
Comment #15
jidrone commentedComment #16
zenimagine commented@jidrone It seems to me very good.
Have you watched how the Open Social custom module works?
It could perhaps serve as a basis.
Comment #17
dalra commentedSounds great!
There also needs to be an option to remove the content from the group.
In the select it could be a None option and maybe a checkbox next to the autocomplete field.
Comment #18
zenimagine commented@jidrone the module should verify that the user has already created a group before creating a new node.
If the user does not have a group and tries to create a node, you must display the group creation form with a message:
"You need to create a group to be able to create content"
Comment #19
dalra commentedDeleted
Comment #20
zenimagine commented@dalra It would be nice to have an option to make it mandatory.
On my site, a user can not create a node if he does not have a group.
Maybe in the field parameter it would be interesting to add this option.
Comment #21
anruetherFrom what I understand, there is quite a bit of the functionality that is being discussed here in this patch: https://www.drupal.org/project/group/issues/2718195#comment-12869526 Marking the issue as related.
This patch introduces a pseudo field which makes it possible to:
- Show which group a node is in on node form and view
- Add/remove groups through the node form (either limited to a specific group type or any group)
Especially the add/remove functionality might not be obvious from the issue title...
Comment #22
jidrone commentedHi Everyone,
Finally I finished a patch with the field approach, I created a widget for the entity reference field called "Group Selector" and a Formatter called "Parent Group Entity".
When you initially configure the field is needed to synchronize it to add the values for existing group content, for that reason I created an option in the field to do that.

You only need to check it the first time, for that reason the default value is unchecked.
It's important to select the Group Content as referenced entity in the field to see this option.
I decided to continue this patch because the solution from #2718195: Add a computed field for entity's group(s), does not cover the purpose of this issue.
IMPORTANT: If you used the previous patch, first uninstall the gcontent module, before to apply this.
Comment #23
zenimagine commented@jidrone Thank you, I will test the patch on Monday
Comment #24
jidrone commentedI forgot to mention that I needed this patch #2939432: Make sure path has a value before calling purge in pathauto_entity_delete() for pathauto.
Comment #25
zenimagine commented@jidrone I applied the patch, but did not understand how it works.
There is no group field in the content.
Comment #26
jidrone commentedHi @zenimagine,
This new patch works as a widget for an entity reference field, so the steps to make it work are the following:
Comment #27
zenimagine commented@jidrone I encounter some problem with the patch, when I edit my node, I have a php error :
Error: Call to undefined method Drupal\gcontent_field\Plugin\Field\FieldWidget\GroupSelectorWidget::buildSelectAddMode() in Drupal\gcontent_field\Plugin\Field\FieldWidget\GroupSelectorWidget->buildAddActions() (line 788 of /var/www/www-domaine-com/web/modules/contrib/group/modules/gcontent_field/src/Plugin/Field/FieldWidget/GroupSelectorWidget.php) #0 /var/www/www-domaine-com/web/modules/contrib/group/modules/gcontent_field/src/Plugin/Field/FieldWidget/GroupSelectorWidget.php(702): Drupal\gcontent_field\Plugin\Field\FieldWidget\GroupSelectorWidget->buildAddActions(Array, 'group_node:arti...') #1 /var/www/www-domaine-com/web/core/lib/Drupal/Core/Field/WidgetBase.php(104): Drupal\gcontent_field\Plugin\Field\FieldWidget\GroupSelectorWidget->formMultipleElements(Object(Drupal\Core\Field\EntityReferenceFieldItemList), Array, Object(Drupal\Core\Form\FormState)) #2 /var/www/www-domaine-com/web/core/lib/Drupal/Core/Field/FieldItemList.php(287): Drupal\Core\Field\WidgetBase->form(Object(Drupal\Core\Field\EntityReferenceFieldItemList), Array, Object(Drupal\Core\Form\FormState)) #3 /var/www/www-domaine-com/web/core/modules/field_ui/src/Form/FieldConfigEditForm.php(99): Drupal\Core\Field\FieldItemList->defaultValuesForm(Array, Object(Drupal\Core\Form\FormState)) #4 /var/www/www-domaine-com/web/core/lib/Drupal/Core/Entity/EntityForm.php(117): Drupal\field_ui\Form\FieldConfigEditForm->form(Array, Object(Drupal\Core\Form\FormState)) #5 [internal function]: Drupal\Core\Entity\EntityForm->buildForm(Array, Object(Drupal\Core\Form\FormState)) #6 /var/www/www-domaine-com/web/core/lib/Drupal/Core/Form/FormBuilder.php(518): call_user_func_array(Array, Array) #7 /var/www/www-domaine-com/web/core/lib/Drupal/Core/Form/FormBuilder.php(275): Drupal\Core\Form\FormBuilder->retrieveForm('field_config_ed...', Object(Drupal\Core\Form\FormState)) #8 /var/www/www-domaine-com/web/core/lib/Drupal/Core/Controller/FormController.php(93): Drupal\Core\Form\FormBuilder->buildForm('field_config_ed...', Object(Drupal\Core\Form\FormState)) #9 [internal function]: Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch)) #10 /var/www/www-domaine-com/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array) #11 /var/www/www-domaine-com/web/core/lib/Drupal/Core/Render/Renderer.php(582): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #12 /var/www/www-domaine-com/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure)) #13 /var/www/www-domaine-com/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) #14 /var/www/www-domaine-com/vendor/symfony/http-kernel/HttpKernel.php(151): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #15 /var/www/www-domaine-com/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) #16 /var/www/www-domaine-com/web/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #17 /var/www/www-domaine-com/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #18 /var/www/www-domaine-com/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(99): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #19 /var/www/www-domaine-com/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(78): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true) #20 /var/www/www-domaine-com/web/core/modules/ban/src/BanMiddleware.php(50): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #21 /var/www/www-domaine-com/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\ban\BanMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #22 /var/www/www-domaine-com/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #23 /var/www/www-domaine-com/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #24 /var/www/www-domaine-com/web/core/lib/Drupal/Core/DrupalKernel.php(669): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #25 /var/www/www-domaine-com/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #26 {main}.Comment #28
zenimagine commentedWill not it be simpler than the module created a lock field ?
Autocomplete works, but the selection list shows the problem above.
Autocomplete displays the relationship content. Groups must be displayed. The name of the relationship is truncated
Comment #29
zenimagine commented@jidrone "Widget: select" does not work on my site.
"Widget: autocomplete" works, but it does not display the group name.
In the autocompletion list, there is the name of the group, but when selected, it displays the name of the relationship.
If I change my knot how to know the group ?
Comment #30
zenimagine commentedComment #31
jidrone commentedHi @zenimagine,
Thank you for all your testing, I will do the following changes in next patch:
Comment #32
zenimagine commented@jidrone Can the sub module directly create a lock field during installation ?
Comment #33
zenimagine commented@jidrone A feature could be very interesting:
If the user does not have a group, when they create a node they should display a message (you must create a group to publish content) and the group creation form.
Comment #34
jidrone commentedHere is the patch with the following fixes and improvements:
Comment #35
jidrone commentedI'm analyzing the possibility to create groups, maybe it could be an improvement in the future if the maintainer thinks the patch is useful.
Comment #36
anruetherDepending on your use casees (you might have others than we have ;) you might find group_behavior useful. It adds a group on node creation for a given content type (via content plugins), there is also groupmediaplus to automatically add media to the nodes group. Sorry for misusing your issue queue, I just wanted to mention it ....
Comment #37
jidrone commentedAnother small fix for the plugin entity cardinality.
Comment #38
zenimagine commented@jidrone Should I uninstall the sub module before applying the patch?
Comment #39
zenimagine commented@jidrone I uninstalled the sub module and reinstalled it again.
I did a quick test:
1) In "Manage View" node, the field does not list any rendered entities. View screenshots
Capture d’écran du 2018-12-13 12-02-19.pngandCapture d’écran du 2018-12-13 12-01-44.png2) When the group is selected, the label of the field disappears. View screenshots
Capture d’écran du 2018-12-13 11-51-08.pngandCapture d’écran du 2018-12-13 11-51-25.png3) Why not create a real selection list as in Drupal Commerce for the store selection for the product. Groups should be listed by type of group. View screenshots
Capture d’écran du 2018-12-13 12-04-32.png4) In the group name ' are replaced by '
Comment #40
jidrone commentedHi @zenimagine,
I fixed the things in comment #39, except the 4 because I didn't understand, is not needed to reinstall the module.
Comment #41
zenimagine commented@jidrone Thank you, it works much better.
In 4 I mean that
'are replaced by'I will continue to test it, but is it essential to have the button "Add group"?
A simple pick list when the field and limited to a single pick will require less manipulation. See the screenshots, for example the "Language" field.
Comment #42
zenimagine commented1) One choice
2) Many choices
Comment #43
zenimagine commentedOne more thing, I have the module https://www.drupal.org/project/message
When I use the token of the group field to display a link to the parent group of the node, this displays the relationship entity with the node.
Normally I should have the name and link of the parent group
Comment #44
jidrone commentedHi @zenimagine,
In this patch I fixed the ' replaced by '
The "Add Group" button is really needed for the ajax functionality in the field items and regarding the token you can follow this great article about how to do it https://www.flocondetoile.fr/blog/token-and-chained-entities-drupal-8
Comment #45
zenimagine commented@jidrone 884/5000
Thanks for the patch, it works.
The character problem is fixed.
I managed to find the right token, with your link.
Just one or two things that may need to be reviewed:
1) in the screenshot
Capture d’écran du 2018-12-14 19-53-27.pngwhen I add a group to the content, this is well presented.2) in the screenshot
Capture d’écran du 2018 12 14 19 52 33.pngwhen I change the group of a content, this is poorly presented. The design is not suitable for the smartphone, I think the "Edit" button and the title of the relationship should not be displayed.3) since this sub-module manages the relations between the groups and the nodes directly on the editing page of the node. Why the module does not prohibit access to the page (this page may be of interest to the site administrator, but not to the group administrator) :
/group/ID/contentand the "Associate Content" and "Add Content" buttons on :
/group/ID/nodes4) with you take a look at the demonstration of open social? try to add content, a selection list is available for groups. But I am not a programmer.
5) There are also chips that appear next to the button. I do not know if this is related to Bootstrap
Comment #46
geek-merlinHuh, we have 3 issues with roughly the same scope:
* (this one) #2813405: Add a field to view and edit content's groups
* #2718195: Add a computed field for entity's group(s)
* #2774533: Better UI for adding content to multiple groups
Let's try to sort this out and consolidate. I'll start with the easiest:
* #2774533: Better UI for adding content to multiple groups - this code looks like included in both other issues so tentatively closing as dup.
* (this one) #2813405: Add a field to view and edit content's groups - I did not test this patch, but code-wise it looks well elaborated. chapeau! alas, it suffers from a denormalized design to take a entityreference field and sync it to group relation.
* #2718195: Add a computed field for entity's group(s) - a computed field that has no storage and loads and stores from group relation.
I'd suggest to consolidate the patches by replacing this patch's field syncing with the other patches much cleaner computed field approach.
(Of course YMMV and we can query a maintainer verdict about that)
Comment #47
geek-merlinComment #48
jidrone commentedHi @axel.rutz,
I didn't test the #2718195: Add a computed field for entity's group(s), does it allow to add the content to the group from the entities form?.
I'm asking because this patch allows all View, Add, Edit and Remove.
Comment #49
anruether> I'm asking because this patch allows all View, Add, Edit and Remove.
Yes, it does. I mentioned that earlier. What exactly do you mean by edit? Do you mean the group relation? I'm not sure if this can/should be done in the field widget... Apart from that you can View, Add and Remove with the other patch.
Comment #50
jidrone commentedI'm testing #2718195: Add a computed field for entity's group(s), to see if we can replace the field syncing as @axel.rutz propose.
Comment #51
jidrone commentedThis new patch includes the suggestion from @axel.rutz, instead of syncing field storage, it creates a computed field called "Group content" ready to use on entities from Group Content Plugins.
Thanks @axel.rutz.
Comment #52
zenimagine commented@jidrone Thank you, the sub module is already installed on my site. To update to the new patch, should you uninstall your module? Thank you
Comment #53
jidrone commentedHi @zenimagine,
You don't need to uninstall, just rebuild cache and this time the field will appear automatically, so you don't need to create it.
Comment #54
zenimagine commented@jidrone Currently I have created fields for the previous patch. It is no longer useful ?
Comment #55
jidrone commentedHi @zenimagine,
They are no longer useful, because they depends on field storage and previous syncing functionality, I recommend you to use the new one.
Comment #56
zenimagine commented@jidrone Thank you, the patch works. But I see 2 problems:
- the rendered entities of the group do not correspond to the displays of the group type.
- it is not possible to limit the relation to a single group (single selection).
Comment #57
zenimagine commented@jidrone When I turn on the group in the node type view, it displays the name of the relationship. You must display the name of the group.
The field should also be required
Comment #58
zenimagine commentedIf the field is not configurable, maybe the solution would be to add parameters for the group in edit the node type
Comment #59
jidrone commentedHi @zenimagine,
I added those options to the widget, the default values are Multiple: Yes and Required No.
Regarding the view modes for the groups, the default formatter is rendered entity, but the entity type being referenced is the group content, to show the group you will need to select "Parent Group Entity" as formatter in Manage Display.
Comment #60
zenimagine commented@jidrone Super thank you, it works. It misses the label of the field, once it is selected
Would it be possible to customize the label of the field "Group content" in the widget?
Comment #61
zenimagine commentedI think only the name of the group should be displayed. The name of the relationship of the content is not useful
Comment #62
zenimagine commentedThe group field in the node edit form for the multivalue is more convenient in the patch below.
With your last patch and the changes you've made, maybe it's possible to create the same rendering for multiple values. As well as a simple list for a single value.
https://www.drupal.org/project/group/issues/2718195
Comment #63
jidrone commentedHi @zenimagine,
The reason why I don't follow that approach is because in the patch you mentioned is only posible to reference the group, so is not possible to set any custom fields you have configured for the content plugin and other important case is for users is not possible to assign them a group role.
The field from this patch references the group content which makes more sense and also allow you to completely admin the group content relation, for this reason is needed the ajax behavior and the "Add to group" button.
Comment #64
jidrone commentedThis patch fixes the field label hidden when group is selected and also removes the group content bundle label.
To replace the field label I think it can be done using hook_entity_bundle_field_info_alter, I also removed the inline_entity_form dependency because from patch in comment #22 it's not needed but I forgot to remove it.
Comment #65
zenimagine commented@jidrone Thank you, the label is correctly displayed.
When I click on the "Remove" button, it is the name of the group content that appears in place of the group name.
I can no longer display the token with the "Message" module.
<a href='[message:field_node_reference:entity:group_content:entity:group:url]'>[message:field_node_reference:entity:group_content:entity:group:title]</a>With the field created manually, it will work. Now the code above does not display the group.
Comment #66
jidrone commentedHi @zemagine,
I fixed the name of the group when removing, but the token I think is related with #2794343: Programatically defined fields for custom content entities are not available as tokens in Pathauto from token module.
Comment #67
zenimagine commented@jidrone Thank you, the name of the group is now fixed.
But the open problem for the chips, has been closed and does not fix the problem.
It would be nice to add a token to the module to display the parent group of a node.
Is it normal for the button to use ul and li ?
Comment #68
zenimagine commentedComment #69
jidrone commentedHi @zenimagine,
I added support for token and yes it is normal to see the button as ul and li because it is a dropbutton, in the admin theme it looks good, so you can check how the theme "Seven" does.
Comment #70
zenimagine commented@jidrone Perfect, the token works. Regarding the chips on the buttons, I think there is a problem with the Bootstrap theme. This problem only appears with this module. On the rest of the site, the drop-down buttons are correctly displayed.
Here are some idea of features to add:
- On the page "/admin/content" it would be nice if the module Group adds a column with the parent groups of the nodes. Mass operations could also be added "Add nodes to groups" and "Delete nodes from groups".
- When this sub module is installed, I think it should disable the page "/group/ID/content", which is very confusing for the user. On the "/group/ID/nodes" page, the "Add new content" and "Add existing content" buttons should also be disabled.
- A check should be made when the user creates a node. View a message, if it does not have a group yet "Before creating a content, you must create a group (group creation link)".
- The group content field is limited to groups created by the user, that's fine. But the site administrator should have access to the complete list of groups.
- Maybe this is a problem of my site, but the "Edit" button in the "Group Content" field on the node edit page does not work.
That's it for now. Thank you for your work.
Comment #71
zenimagine commentedIs it normal that the field is also on the user account ?
Comment #72
jidrone commentedHi @zenimagine,
Here are my thoughts:
"/admin/content" column parent groups:
I think that is a great suggestion but it is out of the scope of this issue, I suggest to create a new issue for that.
Disable "/group/ID/content":
This field added by this patch should be an additional functionality, for that reason I don't like the idea to disable core functionalities of group module because both can coexist and can be useful depending of your site roles and group contents administration scenarios.
Group creation link:
I can add a link to create a group if the user has the permissions and there are no available groups.
Access to groups:
This module check the permissions of groups for all the operations and for the list of available groups, so the super admin user should be able to do anything, please check the group types permission and help me to test.
Edit button:
For me it works, maybe other users on this issue queue can test it.
Field on user entity type:
Yes it's ok to see the field on users, that is because this submodule detects all the fieldable entity types which have support for group module via GroupContentEnabler plugin type, the group module adds the "group_membership" for users (this patch allow to create users and add them to groups) and the gnode submodule adds the "group_node" for nodes.
It means if you or someone else add support to other fieldable entity type for group, then the field "group_content" will be available on the entity form.
Comment #73
jidrone commentedComment #74
jonathanshaw@jidrone The work you've done here on a computed reverse reference field, and especially on the corresponding widget, is great. I can see many use cases for this outside of group too. How much work do you think it would be to generalise it into its own contrib module that could be used with any entity reference field; the Group module could then have an optional dependency on this new contrib module.
Comment #75
maxilein commentedIf you research this, please consider the functionality of the cer module.
Comment #76
jidrone commentedHi @jonathanshaw,
I think the formatter I created in this patch is totally intended to be use with groups, then if the module proposed by @maxilein does not provide a generalized way to do this maybe we can help on that module or create a new contrib.
Comment #77
zenimagine commented@jidrone Hi, when I try to add a group, it does not work and I have an error :
Emplacement https://www.domaine.com/fr/node/243/edit?_wrapper_format=drupal_ajax&aja...
Référent https://www.domaine.com/fr/node/243/edit
Error: Call to a member function getContentPlugin() on null in Drupal\gcontent_field\Plugin\Field\FieldWidget\GroupSelectorWidget->formMultipleElements() (line 711 of /var/www/www-domaine-com/web/modules/contrib/group/modules/gcontent_field/src/Plugin/Field/FieldWidget/GroupSelectorWidget.php) #0 /var/www/www-domaine-com/web/core/lib/Drupal/Core/Field/WidgetBase.php(104): Drupal\gcontent_field\Plugin\Field\FieldWidget\GroupSelectorWidget->formMultipleElements(Object(Drupal\gcontent_field\Field\GcontentFieldItemList), Array, Object(Drupal\Core\Form\FormState)) #1 /var/www/www-domaine-com/web/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php(171): Drupal\Core\Field\WidgetBase->form(Object(Drupal\gcontent_field\Field\GcontentFieldItemList), Array, Object(Drupal\Core\Form\FormState)) #2 /var/www/www-domaine-com/web/core/lib/Drupal/Core/Entity/ContentEntityForm.php(125): Drupal\Core\Entity\Entity\EntityFormDisplay->buildForm(Object(Drupal\node\Entity\Node), Array, Object(Drupal\Core\Form\FormState)) #3 /var/www/www-domaine-com/web/core/modules/node/src/NodeForm.php(115): Drupal\Core\Entity\ContentEntityForm->form(Array, Object(Drupal\Core\Form\FormState)) #4 /var/www/www-domaine-com/web/core/lib/Drupal/Core/Entity/EntityForm.php(117): Drupal\node\NodeForm->form(Array, Object(Drupal\Core\Form\FormState)) #5 [internal function]: Drupal\Core\Entity\EntityForm->buildForm(Array, Object(Drupal\Core\Form\FormState)) #6 /var/www/www-domaine-com/web/core/lib/Drupal/Core/Form/FormBuilder.php(518): call_user_func_array(Array, Array) #7 /var/www/www-domaine-com/web/core/lib/Drupal/Core/Form/FormBuilder.php(368): Drupal\Core\Form\FormBuilder->retrieveForm('node_partenaire...', Object(Drupal\Core\Form\FormState)) #8 /var/www/www-domaine-com/web/core/lib/Drupal/Core/Form/FormBuilder.php(625): Drupal\Core\Form\FormBuilder->rebuildForm('node_partenaire...', Object(Drupal\Core\Form\FormState), Array) #9 /var/www/www-domaine-com/web/core/lib/Drupal/Core/Form/FormBuilder.php(318): Drupal\Core\Form\FormBuilder->processForm('node_partenaire...', Array, Object(Drupal\Core\Form\FormState)) #10 /var/www/www-domaine-com/web/core/lib/Drupal/Core/Controller/FormController.php(93): Drupal\Core\Form\FormBuilder->buildForm('node_partenaire...', Object(Drupal\Core\Form\FormState)) #11 [internal function]: Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch)) #12 /var/www/www-domaine-com/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array) #13 /var/www/www-domaine-com/web/core/lib/Drupal/Core/Render/Renderer.php(582): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #14 /var/www/www-domaine-com/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure)) #15 /var/www/www-domaine-com/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) #16 /var/www/www-domaine-com/vendor/symfony/http-kernel/HttpKernel.php(151): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #17 /var/www/www-domaine-com/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) #18 /var/www/www-domaine-com/web/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #19 /var/www/www-domaine-com/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #20 /var/www/www-domaine-com/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(99): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #21 /var/www/www-domaine-com/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(78): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true) #22 /var/www/www-domaine-com/web/core/modules/ban/src/BanMiddleware.php(50): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #23 /var/www/www-domaine-com/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\ban\BanMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #24 /var/www/www-domaine-com/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #25 /var/www/www-domaine-com/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #26 /var/www/www-domaine-com/web/core/lib/Drupal/Core/DrupalKernel.php(693): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #27 /var/www/www-domaine-com/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #28 {main}.
Comment #78
jidrone commentedHi @zenimagine,
I was testing but I couldn't reproduce that error.
Comment #79
zenimagine commented@jidrone This problem only appears with the site administrator. For the user to work
Comment #80
jidrone commentedI couldn't reproduce the error with different scenarios.
This patch only improves the access to field when editing own user account and the message when reached entity cardinality.
Comment #81
jidrone commentedSmall usability improvement, the relation field gets cleared after new relation is added.
Comment #82
jidrone commentedComment #83
zenimagine commented@jidrone Thank you, I tested the patch and I still have the same error. I do not know where it comes from.
Comment #84
zenimagine commented@jidrone When I open the ajax link, I have the message below, but I do not understand what it means :
[{"command":"insert","method":"prepend","selector":null,"data":" \u003Cdiv role=\u0022contentinfo\u0022 aria-label=\u0022Error message\u0022 class=\u0022messages messages--error\u0022\u003E\n \u003Cdiv role=\u0022alert\u0022\u003E\n \u003Ch2 class=\u0022visually-hidden\u0022\u003EError message\u003C\/h2\u003E\n An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (24 MB) that this server supports.\n \u003C\/div\u003E\n \u003C\/div\u003E\n ","settings":null}]Comment #85
zenimagine commented@jidrone Have you tested the module with several types of groups?
With one type of group it works, but with the others, I have this error and nothing happens.
Comment #86
zenimagine commented@jidrone I asked the question on stackexchange and a user replied :
Comment #87
jidrone commentedHi @zenimagine,
Try this small change.
Comment #88
zenimagine commented@jidrone I will test that. Have you managed to reproduce the problem ?
Comment #89
zenimagine commented@jidrone I applied the patch, but that does not solve the problem.
With one type of group it works, but not with the other type of group.
Comment #90
dwwThanks for all the work here so far! This is getting close to a very useful feature.
In addition to the unresolved bug from #77 through #89, I'm setting to needs work for a few more things:
1. There's no obvious way to change the "Group content" label. Yes, I could form alter the widget and entity_view_alter to fix the display, but wow that's a lot of work. I know this is a "magic" field that appears automatically, but it'd be great if it also appeared on 'manage fields' in some way, at least to let you change the name/label.
Eventually it could support other goodies that normally appear at manage fields, like required, default value, etc., but that might get too complicated and should probably be a follow-up issue.
2. We should also consider if "Group content" makes sense as the default label for this, regardless of if you can easily customize it. It's really "Groups this content belongs to" or even just "Groups" (in the context of a field on site content). If I'm looking at, say, an event that can belong to multiple groups, the things this field shows me are the groups the event belongs to. The event is the "group content", and this field is really pointing to the groups themselves.
3. It'd be better if once you enable this, a site builder gets to turn it *on* on the 'Manage form display' page for any entity types that make sense, instead of having to manually turn it off everywhere it doesn't.
4. If I login as a group admin, the help text needs help:
"Group content" should be configurable (see #1 above).
a. "No added yet to groups.:"
Should be: "Not yet added to groups." or even "Not in any groups."
b. "Type a group"
This is a (not very helpful) description, but the form element it describes has no label (making this an accessibility bug). I think there should be a "Group name" label, then you don't need the description at all. The call-to-action remains "Add to Group".
5. If you press "Add to Group" without typing a group name, nothing happens, no error or warning is generated.
6. If the content does not yet belong to any groups, and you type an invalid name and try to "Add to Group", the name is marked red, but there's no other error message:
We need to display the form validation error messages in this case.
7. If you successfully add the content to a group, then try again with something invalid, you now see an error message, but it's generic and not very user-facing-friendly:
Should be something like:
There are no groups named "%group_name".8. If I login as a user that belongs to a few groups, but doesn't have permission to post anything to those groups, and I try to create content that *could* be associated with a group (but not by me), I get the following error message:
If the current user doesn't have permission to add content to a group, the widget should hide those aspects completely, and only show current group memberships in a read-only listing.
9. Configuring display is clumsy. If I use 'label', I get the label of the association between the content and each group. This always duplicates the name of the content itself, and as a site-builder or end user, it just seems like a bug. If I choose "entity ID" I see that they're unique entities, even though the labels are equivalent. If I use 'rendered entity' I get the full rendered entity of the association of the content and each group, again, totally useless for me to see as an end user. The only option that actually makes any sense here is "Parent group entity", but then I'm forced to use a view mode to render the full entity. At this point, I have to add a new 'Name-only' view mode of group entities, then come back to configure the display of every content type on my site to click a few different times on each of these 'Group content' field formatters. :(
I can't imagine a scenario where you want to see the group-association entities with this formatter. Why doesn't it immediately assume you're talking about the parent group, and then retain the options for label-only (with and without a link to the group entity itself), id, or a full rendered entity? Or if there's a reasonable use-case for seeing the group-content-association entities, make that the special case that requires more clicks.
10. It'd be great to have some functional tests for all these cases. Stretch goal. ;) I leave it to the maintainers to decide if this is a requirement.
Comment #91
jidrone commentedHi Everyone,
Here is the new patch with some improvements suggested in #90:
Then you can set the formatter as referenced entity and show a summary of user membership.
By default the field is hidden from display and with the mentioned scenario I think is better not to assume the field formatter as parent group
Comment #93
jidrone commentedMoved to needs review, it didn't pass the PHP5 tests because it uses php ternary null coalescing added in PHP7, but I think it is not a blocker because php 5 support will end soon.
Comment #94
geek-merlinJup: Drupal 8 will require PHP 7 starting March 6, 2019 (one year from now); PHP 7.1+ recommended | Drupal Groups
Comment #95
zenimagine commented@jidrone thank you for this update.
However there is some detail to settle.
No label is set by default, so only the required field star appears if I do not customize the label.
I noticed that users tend to select a group and save the content without clicking the "Add a group" button. The content shows a wander in the form but it is not obvious to them.
Comment #96
balbuf commentedI am receiving the same error as @zenimagine in #77 with latest patch and as Administrator.
I would also echo @zenimagine's comment in #95 regarding the "Add to Group" button. Ideally, the groups would just be connected upon saving the actual piece of content, eliminating the extra step.
Thank you for your work on this @jidrone! I will see if I can dig in and contribute anything.
Comment #97
scotwith1tI believe the reason for the "Add to Group" step is a data integrity issue: so that required fields aren't left empty on the Relationship entity. For instance, for Group Membership plugin you likely will have to fill out the Group Membership entity (group roles field to fill out, along with any other custom membership entity fields in order for the "groups to just be connected". I suppose if the 2-step wizard is disabled for a plugin, maybe then you could safely skip that step, since the configuration is such that this step is skipped when creating the Relationship entity directly (rather than via the related entity's form via this new field widget). Hope that makes sense...
Comment #98
balbuf commented@scotself good point about having additional fields on the Relationship entity. I wasn't thinking about that because 1) I don't yet have any need to add fields on the Relationship entity, and 2) I can't get this patch to work to even see what the UX flow looks like in terms of filling such fields when adding new groups to a piece of content.
Comment #99
balbuf commentedI created a new patch based of the one in #45 here: https://www.drupal.org/project/group/issues/2718195#comment-12869526
What I liked about that code is that it inherently supports any display widgets that an EntityReference field supports, and it doesn't require the additional "Add to Group" step. (However, I hadn't considered the additional Relationship fields @scotself mentioned in #97 - I'm not sure how those would be handled.)
Anyway, I took that patch as a starting point and leveraged some of @jidrone's logic to restrict group relationship addition/removal based on the appropriate permissions. I also added logic such that the computed field is only added to content types that are enabled for one or more groups.
Perhaps this may be useful to someone!
Comment #101
geek-merlinSo the current patch is #91 and #99 is a case study based on old #45? Wouldn't it be good to improve #91?
Comment #102
jidrone commentedHi everyone, I will work on this again on next week.
Comment #103
zenimagine commented@jidrone Maybe you could find help here https://www.drupal.org/project/gnode_field
Comment #104
dwwRe: @zenimagine #103: how could we possibly know? ;) There's no description on the project page. I cloned the repo and there's no README or anything. I looked in gnode_field_help() and found only this:
$output .= '<p>' . t('Functionality as it relates to groups on the site.')I have no idea WTF that module is for. ;) Hah, just found #3033566: Hi, what is this module for ? ;)
Oh, at least gnode_field.info.yml has this:
description: Add groups directly from the node form.Guess I should have looked there before hook_help. Oh well...
Anyway, yeah, it seems quite overlapping. Would be great to merge efforts if possible, get this functionality working here and deprecate that project so we don't end up with splintered/forked modules for the same feature.
Thanks for the pointer!
-Derek
Comment #105
balbuf commented@axel.rutz #2718195-45: Add a computed field for entity's group(s) was a better starting point for me because it worked / produced no errors, allowed me to use any entity reference widget (in my case I want to use a checkbox list), eliminated the extra "Add to Group" step, and was comparatively simpler code. That may be an older patch and a closed issue, but it's still valuable work.
Per the issue of a group content entity allowing additional fields, I feel like this would be best handled with the optional 2-step wizard. On the content edit screen you'd select the groups you want, then, based on the selected groups, show the group content form for each selected group (IF the wizard is enabled - for instances where the group content entity has no additional fields, you just disable the wizard to eliminate this step). Not sure how your patch handles it @jidrone, but I think this would be the most flexible and ideal UX.
Comment #106
dalra commented@balbuf
Would your patch allow for a radio button list of groups to be displayed on an article?
In the article node, I would like to allow users to choose a group from a radio list and click save.
This would add an article to a group with just 2 clicks.
Also, I would like the content to be in just one group (Public or Private).
If the content is already in the Public group and the user adds it to the Private group, the content needs to removed from the Public group.
Would that be possible with your patch?
Thank you
Comment #107
dan_metille commentedI have applied patch #91, but cannot enable 'gcontent_field' module, as it is complaining about my Entity module version:
Entity (>=8.x-1.0-rc1) (incompatible with version )I have tried with both 1.0-rc1 and 1.0-dev version of Entity, without success.
EDIT: I could enable the module via Drupal Consol.
Comment #108
geek-merlin#107:
> Entity (>=8.x-1.0-rc1)
i do not see that line in the patch. Alas, if it's in a info.yml file, it should read:
> Entity (>=1.0-rc1)
Comment #109
anruetherTesting #91, some remarks:
1. The Group selection on node/add forms needs the "Relationship: Add entity relation" permission, although the "Entity: Add content entities" permission should suffice
2. If the user does not have the permission to remove a relation, he cannot change the group again. This seems to be a bit strict, since the node does not exists yet
3. It only works with the default group type, not with any custom group type. There I'm getting a similar error as #77:
Comment #110
esolitosHello, I've found the patch from https://www.drupal.org/project/group/issues/2718195 in Open Social, now I need to implement a similar thing and I wonder: what patch should I use here to be "future=proof"?
I see two completely different approaches and I fear that choosing the wrong one will cause issues on the long run, so just wondering what's the general opinion here for the future.
Comment #111
dwwWe've now got 3 possible options:
Fun. ;)
I can't give any recommendation on the "future-proof" choice. :(
Would love to get everyone into a shared conversation about it. Not sure if this issue is the best place for that. #d8-group in Drupal Slack? DrupalCon bof with a remote option (Zoom, Slack, etc?). I'm not yet clear who "everyone" means. :/
@kristiaanvandeneynde group maintainer
@scottalan from gnode_field
@jidrone from #91
@joachim, @axel.rutz, @modestmoes, @recrit, @realityloop, @adammalone et al from #2718195
... ?
Thoughts on how to proceed?
Thanks!
-Derek
p.s. Opened #3045046: Consider merging this into group module? to ping @alanscott as the maintainer of gnode_field.
Comment #112
geek-merlin@dww,
Derek, thanks for bringing this up so we can sort out this whole mess.
* Looked into https://www.drupal.org/project/gnode_field. That module uses a form_alter approach that i'd strongly discourage.
* My comments from #46 still apply so i'd strongly advise going with #91 and not the closed issue
Also, until drupal.org supports a branch-per-issue, someone(tm) might open a sandbox and invite everyone here.
With a complex patch like this one this might really help. (Just my 2 cents, i don't think i can put much bandwidth in here.)
Comment #113
joachim commentedIsn't this going to be circular?
Comment #114
geek-merlinClarifiing current patch (which the last question correctly refers to).
Comment #115
scotwith1tFWIW, we're using #91 in a project for the last couple months and haven't had any issues thus far.
Comment #116
geek-merlin> FWIW, we're using #91 in a project for the last couple months and haven't had any issues thus far.
OK, setting this to RTBC to bug @kristiaanvandeneynde and get his review on this.
It would be really nice if we get this in soon and move forther improvements into a followup.
Comment #117
anruetherSetting back to Needs work, for #91 we have some comments in #90 which have not been addressed and #109:
Does not work for any other group type than the default group type mentioned in #85 and #109
Some points from #90 not yet addressed, such as
Please see #90 (#91 for what has been taken care of) and #109
Also, I would add, that the form widget is also clumsy and missleading. On default autocomplete is enabled which let's you select a list of all content. The custom widget "Group Selector" is what you want. I hoped there is a more standard way to use existing widgets and formatters...
Comment #118
dwwGlad to see this moving forward. Yes, needs work. :) I started reviewing #91. Agreed that there are still a number of items from #90 not yet addressed. Also found these:
No newline
A) 'Defines a group content field type.'
- Needs a period.
- Simpler language more in line with core field types (image, text, etc).
Or:
B) 'Defines a group content relationship field type.'
or very wordy, and referring to things we don't normally want to say in the user-facing text like "entity", but even more descriptive:
C) 'Defines a field type to associate content with groups directly on the entity form.'
?
This shouldn't be here, and will be added by d.o during packaging.
And here
Maybe:
"Get entities that should have a group content field."
?
This seems like a weird way to test if the entity type in question is field-able. There must be a cleaner way to to this that doesn't depend on field_ui. Can't we test if something implements a certain interface, instead?
Can we be more flexible here and honor a config setting or something to make this field opt-in instead of opt-out? Basically #90.3 (I think).
s/an/a
Could shorten the text to:
'Many groups are called %value. Pick one by appending the ID in parentheses, like "@value (@id)".'
Nice touch with the error message here!
However, it's more wordy than needed. Could be:
'Multiple groups match: "%multiple". Pick one by appending the ID in parentheses, like "@value (@id)".'
Stopping review here for now...
No time for further review.
It does seem like a shared branch somewhere in a sandbox of some sort could be helpful. d.o sandbox? GitLab? GitHub? Thoughts?
Thanks!
-Derek
Comment #119
dwwI created a d.o sandbox:
https://www.drupal.org/sandbox/dww/3045926
Clone of group module's 8.x-1.x branch.
I pushed a 2813405-group-content-field branch with #91 from here as commit c34f0ed.
Also pushed commit 6356f92 to fix #118 except points 6 and 7.
I added @jidrone, @axel.rutz, @joachim as co-maintainers. If anyone else wants access, please let me know.
Can we concentrate our efforts there to get this actually RTBC?
Thanks!
-Derek
Comment #120
geek-merlin> I created a d.o sandbox:
❤ to work with you!
Comment #121
jidrone commentedGreat, I will check this as soon as I can.
Comment #122
jidrone commentedAddressed all things on #109 and the point 6 of #118
Comment #123
dwwWhoops, #122 is empty. But based on the sandbox project, I think this is what @jidrone meant to upload. I haven't reviewed or tested it, but it's got some commits from both me and @jidrone in it. ;) Interdiff relative to #91 attached.
Still needs work for more from #90, but calling this NR to see what the testbot and others think.
Comment #124
jidrone commentedHere is the new patch with 118.6 resolved, maybe I didn't pushed to sandbox before I created the patch.
Regarding the 118.7, related to 90.3, I wrote in 91 that I did the right code based on Drupal documentation but it was setting the field visible by default anyway. But after my latest tests it is working as expected and now the field should be configured in "Manage form display" to appear.
I someone else can test it, then we can say all issues from 90 and 118 are resolved.
Comment #125
catchJust a note I'll be testing the latest patch for a client project over the next week or so, was thinking of creating a computed field to do this then fortunately found this issue first.
Comment #126
dww@catch: Great! I made you co-maintainer on https://www.drupal.org/sandbox/dww/3045926 if you want to push any commits there.
I'll also be doing another round of review + testing on this for a project in the next few days. Hopefully we can coordinate any fixes and avoid duplicating any work. Here or #d8-group in Slack. I'm not at DrupalCon, sadly.
Thanks!
-Derek
Comment #127
catchMinor, but there's a null coalesce operator in gcontent_field.module which means a syntax error on PHP 5.6. Core's about to drop support for PHP 5.6 with 8.7.x but it'll still be supported by 8.6.0 a bit longer.
Comment #128
catchThree more.
Comment #129
jidrone commentedDrupal 8.6 will still support PHP 5.6, but that version of PHP is an unsupported version by the PHP maintainers and for that reason most of the hosting providers already support PHP 7, so I think we don't need to downgrade the code, but if other users agree with you we can change it.
Comment #130
jidrone commentedHi Everyone, did someone has time to test this patch with the latest improvements?
Comment #131
esolitosI've been using patch from #124 for a while now, not in prod but on a quite complex site under heavy development, no big issue encountered.
Comment #132
scotwith1tSame as @esolitos, we've not launched the project, but it's quite complex and we've had no issues with this patch while building out the client's product.
Comment #133
zenimagine commented@jidrone Hi, I currently have the patch 91. Can I update with patch 124 or do I have to uninstall the sub module to update ? Thank you
Comment #134
zenimagine commented@Jidrone I applied patch 124 and the group is not added to the node.
If I select a group and click on added, the addition form disappears and the group is not added.
Comment #135
zenimagine commentedComment #136
zenimagine commentedIf I try to save the node, I have a PHP error :
Drupal\Component\Plugin\Exception\PluginNotFoundException : The "entity:group_content:administrateur-group_node-partenaire" plugin does not exist. Valid plugin IDs for Drupal\Core\TypedData\TypedDataManager are: formatted_price, duration, entity_revision_reference, entity_revision, entity_revision:advancedqueue_queue, entity_revision:block, entity_revision:block_content, entity_revision:block_content:basic, entity_revision:block_content_type, entity_revision:comment, entity_revision:comment:annonce, entity_revision:comment:article, entity_revision:comment:demande, entity_revision:comment:discussion, entity_revision:comment:evenement, entity_revision:comment:itineraire, entity_revision:comment:produit, entity_revision:comment:recette, entity_revision:comment:service, entity_revision:comment_type, entity_revision:commerce_checkout_flow, entity_revision:commerce_log, entity_revision:commerce_order_item_type, entity_revision:commerce_order, entity_revision:commerce_order:default, entity_revision:commerce_order:produit, entity_revision:commerce_order:recurring, entity_revision:commerce_order:service, entity_revision:commerce_order_item, entity_revision:commerce_order_item:default, entity_revision:commerce_order_item:produit, entity_revision:commerce_order_item:recurring_product_variation, entity_revision:commerce_order_item:recurring_standalone, entity_revision:commerce_order_item:service, entity_revision:commerce_order_type, entity_revision:commerce_payment, entity_revision:commerce_payment:payment_default, entity_revision:commerce_payment:payment_manual, entity_revision:commerce_payment_method, entity_revision:commerce_payment_method:paypal, entity_revision:commerce_payment_method:credit_card, entity_revision:commerce_payment_gateway, entity_revision:commerce_currency, entity_revision:commerce_pricelist, entity_revision:commerce_pricelist:commerce_product_variation, entity_revision:commerce_pricelist_item, entity_revision:commerce_pricelist_item:commerce_product_variation, entity_revision:commerce_product_variation_type, entity_revision:commerce_product_variation, entity_revision:commerce_product_variation:default, entity_revision:commerce_product_variation:produit, entity_revision:commerce_product_variation:service, entity_revision:commerce_product_attribute, entity_revision:commerce_product, entity_revision:commerce_product:default, entity_revision:commerce_product:produit, entity_revision:commerce_product:service, entity_revision:commerce_product_type, entity_revision:commerce_product_attribute_value, entity_revision:commerce_product_attribute_value:couleur, entity_revision:commerce_product_attribute_value:masse, entity_revision:commerce_product_attribute_value:taille, entity_revision:commerce_product_attribute_value:temps, entity_revision:commerce_product_attribute_value:volume, entity_revision:commerce_promotion_coupon, entity_revision:commerce_promotion, entity_revision:commerce_subscription, entity_revision:commerce_subscription:standalone, entity_revision:commerce_subscription:product_variation, entity_revision:commerce_billing_schedule, entity_revision:commerce_order_report, entity_revision:commerce_order_report:order_report, entity_revision:commerce_order_report:order_items_report, entity_revision:commerce_order_report:tax_report, entity_revision:commerce_order_report:promotion_report, entity_revision:commerce_shipment_type, entity_revision:commerce_shipping_method, entity_revision:commerce_package_type, entity_revision:commerce_shipment, entity_revision:commerce_shipment:default, entity_revision:commerce_store, entity_revision:commerce_store:online, entity_revision:commerce_store:personnel, entity_revision:commerce_store:professionnel, entity_revision:commerce_store_type, entity_revision:commerce_tax_type, entity_revision:contact_form, entity_revision:contact_message, entity_revision:contact_message:feedback, entity_revision:contact_message:personal, entity_revision:content_moderation_state, entity_revision:crop_type, entity_revision:crop, entity_revision:crop:1_1, entity_revision:crop:2_1, entity_revision:crop:3_1, entity_revision:crop:3_2, entity_revision:crop:a4, entity_revision:editor, entity_revision:entity_legal_document_acceptance, entity_revision:entity_legal_document, entity_revision:entity_legal_document_version, entity_revision:entity_legal_document_version:cgu, entity_revision:entity_legal_document_version:mentions_legales, entity_revision:entity_legal_document_version:politique_de_confidentialite, entity_revision:field_config, entity_revision:field_storage_config, entity_revision:field_validation_rule_set, entity_revision:file, entity_revision:filter_format, entity_revision:flag, entity_revision:flagging, entity_revision:flagging:like_group, entity_revision:flagging:like_node, entity_revision:flagging:like_product, entity_revision:flagging:like_store, entity_revision:flagging:report_comment, entity_revision:flagging:report_group, entity_revision:flagging:report_node, entity_revision:flagging:report_private_message, entity_revision:flagging:report_product, entity_revision:flagging:report_profile, entity_revision:flagging:report_store, entity_revision:flagging:report_user, entity_revision:group_role, entity_revision:group_type, entity_revision:group, entity_revision:group:administrateur, entity_revision:group:personnel, entity_revision:group:professionnel, entity_revision:group_content, entity_revision:group_content:administrateur-group_membership, entity_revision:group_content:administrateur-group_node-guide, entity_revision:group_content:group_content_type_019ce60735906, entity_revision:group_content:group_content_type_0a627b6b58289, entity_revision:group_content:group_content_type_28f8a8dbd2f8b, entity_revision:group_content:group_content_type_9307df917f9ab, entity_revision:group_content:group_content_type_b1946b84b0196, entity_revision:group_content:group_content_type_ec36c5a835021, entity_revision:group_content:group_content_type_fa2db4a50c8e0, entity_revision:group_content:personnel-group_membership, entity_revision:group_content:personnel-group_node-annonce, entity_revision:group_content:personnel-group_node-article, entity_revision:group_content:personnel-group_node-discussion, entity_revision:group_content:personnel-group_node-evenement, entity_revision:group_content:personnel-group_node-itineraire, entity_revision:group_content:personnel-group_node-recette, entity_revision:group_content:professionnel-group_membership, entity_revision:group_content:professionnel-group_node-annonce, entity_revision:group_content:professionnel-group_node-article, entity_revision:group_content:professionnel-group_node-recette, entity_revision:group_content_type, entity_revision:image_style, entity_revision:language_content_settings, entity_revision:configurable_language, entity_revision:media, entity_revision:media:audio, entity_revision:media:file, entity_revision:media:image, entity_revision:media:remote_video, entity_revision:media:video, entity_revision:media_type, entity_revision:message_template, entity_revision:message, entity_revision:message:mas_create_comment, entity_revision:message:mas_create_group, entity_revision:message:mas_create_node, entity_revision:message:mas_create_product, entity_revision:message:mas_create_store, entity_revision:message:mas_user_register, entity_revision:message:notify, entity_revision:message:private_message_notification, entity_revision:metatag_defaults, entity_revision:node_type, entity_revision:node, entity_revision:node:annonce, entity_revision:node:article, entity_revision:node:demande, entity_revision:node:discussion, entity_revision:node:evenement, entity_revision:node:guide, entity_revision:node:itineraire, entity_revision:node:page, entity_revision:node:partenaire, entity_revision:node:question, entity_revision:node:recette, entity_revision:node:tutoriel, entity_revision:pathauto_pattern, entity_revision:private_message, entity_revision:pm_thread_delete_time, entity_revision:private_message_thread, entity_revision:pm_thread_access_time, entity_revision:profile_type, entity_revision:profile, entity_revision:profile:customer, entity_revision:redirect, entity_revision:responsive_image_style, entity_revision:search_api_index, entity_revision:search_api_server, entity_revision:search_api_task, entity_revision:search_api_autocomplete_search, entity_revision:solr_field_type, entity_revision:menu, entity_revision:action, entity_revision:taxonomy_term, entity_revision:taxonomy_term:annonce_categories, entity_revision:taxonomy_term:annonce_tags, entity_revision:taxonomy_term:article_tags, entity_revision:taxonomy_term:boutique_tags, entity_revision:taxonomy_term:discussion_tags, entity_revision:taxonomy_term:evenement_tags, entity_revision:taxonomy_term:groupe_tags, entity_revision:taxonomy_term:itineraire_tags, entity_revision:taxonomy_term:page_tags, entity_revision:taxonomy_term:produit_labels, entity_revision:taxonomy_term:produit_tags, entity_revision:taxonomy_term:profil_sexe, entity_revision:taxonomy_term:question_categories, entity_revision:taxonomy_term:recette_categories, entity_revision:taxonomy_term:recette_ingredients, entity_revision:taxonomy_term:recette_niveaux, entity_revision:taxonomy_term:recette_tags, entity_revision:taxonomy_term:recette_types, entity_revision:taxonomy_term:service_tags, entity_revision:taxonomy_vocabulary, entity_revision:tour, entity_revision:user, entity_revision:user_role, entity_revision:webform, entity_revision:webform_submission, entity_revision:webform_submission:concours_fevrier_2018, entity_revision:webform_submission:invitation, entity_revision:webform_submission:mode_de_livraison, entity_revision:webform_submission:passerelle_de_paiement, entity_revision:webform_submission:supprimer_la_boutique, entity_revision:webform_submission:supprimer_le_compte, entity_revision:webform_submission:supprimer_le_groupe, entity_revision:webform_options, entity_revision:workflow, entity_revision:menu_link_content, entity_revision:view, entity_revision:paragraph, entity_revision:paragraph:evenement_programmations, entity_revision:paragraph:itineraire_poi, entity_revision:paragraph:recette_ingredients, entity_revision:paragraph:recette_instructions, entity_revision:paragraphs_type, entity_revision:entity_form_display, entity_revision:entity_view_display, entity_revision:entity_form_mode, entity_revision:entity_view_mode, entity_revision:date_format, entity_revision:base_field_override, filter_format, metatag, search_api_html, search_api_text, solr_document, solr_field, entity, entity:advancedqueue_queue, entity:block, entity:block_content, entity:block_content:basic, entity:block_content_type, entity:comment, entity:comment:annonce, entity:comment:article, entity:comment:demande, entity:comment:discussion, entity:comment:evenement, entity:comment:itineraire, entity:comment:produit, entity:comment:recette, entity:comment:service, entity:comment_type, entity:commerce_checkout_flow, entity:commerce_log, entity:commerce_order_item_type, entity:commerce_order, entity:commerce_order:default, entity:commerce_order:produit, entity:commerce_order:recurring, entity:commerce_order:service, entity:commerce_order_item, entity:commerce_order_item:default, entity:commerce_order_item:produit, entity:commerce_order_item:recurring_product_variation, entity:commerce_order_item:recurring_standalone, entity:commerce_order_item:service, entity:commerce_order_type, entity:commerce_payment, entity:commerce_payment:payment_default, entity:commerce_payment:payment_manual, entity:commerce_payment_method, entity:commerce_payment_method:paypal, entity:commerce_payment_method:credit_card, entity:commerce_payment_gateway, entity:commerce_currency, entity:commerce_pricelist, entity:commerce_pricelist:commerce_product_variation, entity:commerce_pricelist_item, entity:commerce_pricelist_item:commerce_product_variation, entity:commerce_product_variation_type, entity:commerce_product_variation, entity:commerce_product_variation:default, entity:commerce_product_variation:produit, entity:commerce_product_variation:service, entity:commerce_product_attribute, entity:commerce_product, entity:commerce_product:default, entity:commerce_product:produit, entity:commerce_product:service, entity:commerce_product_type, entity:commerce_product_attribute_value, entity:commerce_product_attribute_value:couleur, entity:commerce_product_attribute_value:masse, entity:commerce_product_attribute_value:taille, entity:commerce_product_attribute_value:temps, entity:commerce_product_attribute_value:volume, entity:commerce_promotion_coupon, entity:commerce_promotion, entity:commerce_subscription, entity:commerce_subscription:standalone, entity:commerce_subscription:product_variation, entity:commerce_billing_schedule, entity:commerce_order_report, entity:commerce_order_report:order_report, entity:commerce_order_report:order_items_report, entity:commerce_order_report:tax_report, entity:commerce_order_report:promotion_report, entity:commerce_shipment_type, entity:commerce_shipping_method, entity:commerce_package_type, entity:commerce_shipment, entity:commerce_shipment:default, entity:commerce_store, entity:commerce_store:online, entity:commerce_store:personnel, entity:commerce_store:professionnel, entity:commerce_store_type, entity:commerce_tax_type, entity:contact_form, entity:contact_message, entity:contact_message:feedback, entity:contact_message:personal, entity:content_moderation_state, entity:crop_type, entity:crop, entity:crop:1_1, entity:crop:2_1, entity:crop:3_1, entity:crop:3_2, entity:crop:a4, entity:editor, entity:entity_legal_document_acceptance, entity:entity_legal_document, entity:entity_legal_document_version, entity:entity_legal_document_version:cgu, entity:entity_legal_document_version:mentions_legales, entity:entity_legal_document_version:politique_de_confidentialite, entity:field_config, entity:field_storage_config, entity:field_validation_rule_set, entity:file, entity:filter_format, entity:flag, entity:flagging, entity:flagging:like_group, entity:flagging:like_node, entity:flagging:like_product, entity:flagging:like_store, entity:flagging:report_comment, entity:flagging:report_group, entity:flagging:report_node, entity:flagging:report_private_message, entity:flagging:report_product, entity:flagging:report_profile, entity:flagging:report_store, entity:flagging:report_user, entity:group_role, entity:group_type, entity:group, entity:group:administrateur, entity:group:personnel, entity:group:professionnel, entity:group_content, entity:group_content:administrateur-group_membership, entity:group_content:administrateur-group_node-guide, entity:group_content:group_content_type_019ce60735906, entity:group_content:group_content_type_0a627b6b58289, entity:group_content:group_content_type_28f8a8dbd2f8b, entity:group_content:group_content_type_9307df917f9ab, entity:group_content:group_content_type_b1946b84b0196, entity:group_content:group_content_type_ec36c5a835021, entity:group_content:group_content_type_fa2db4a50c8e0, entity:group_content:personnel-group_membership, entity:group_content:personnel-group_node-annonce, entity:group_content:personnel-group_node-article, entity:group_content:personnel-group_node-discussion, entity:group_content:personnel-group_node-evenement, entity:group_content:personnel-group_node-itineraire, entity:group_content:personnel-group_node-recette, entity:group_content:professionnel-group_membership, entity:group_content:professionnel-group_node-annonce, entity:group_content:professionnel-group_node-article, entity:group_content:professionnel-group_node-recette, entity:group_content_type, entity:image_style, entity:language_content_settings, entity:configurable_language, entity:media, entity:media:audio, entity:media:file, entity:media:image, entity:media:remote_video, entity:media:video, entity:media_type, entity:message_template, entity:message, entity:message:mas_create_comment, entity:message:mas_create_group, entity:message:mas_create_node, entity:message:mas_create_product, entity:message:mas_create_store, entity:message:mas_user_register, entity:message:notify, entity:message:private_message_notification, entity:metatag_defaults, entity:node_type, entity:node, entity:node:annonce, entity:node:article, entity:node:demande, entity:node:discussion, entity:node:evenement, entity:node:guide, entity:node:itineraire, entity:node:page, entity:node:partenaire, entity:node:question, entity:node:recette, entity:node:tutoriel, entity:pathauto_pattern, entity:private_message, entity:pm_thread_delete_time, entity:private_message_thread, entity:pm_thread_access_time, entity:profile_type, entity:profile, entity:profile:customer, entity:redirect, entity:responsive_image_style, entity:search_api_index, entity:search_api_server, entity:search_api_task, entity:search_api_autocomplete_search, entity:solr_field_type, entity:menu, entity:action, entity:taxonomy_term, entity:taxonomy_term:annonce_categories, entity:taxonomy_term:annonce_tags, entity:taxonomy_term:article_tags, entity:taxonomy_term:boutique_tags, entity:taxonomy_term:discussion_tags, entity:taxonomy_term:evenement_tags, entity:taxonomy_term:groupe_tags, entity:taxonomy_term:itineraire_tags, entity:taxonomy_term:page_tags, entity:taxonomy_term:produit_labels, entity:taxonomy_term:produit_tags, entity:taxonomy_term:profil_sexe, entity:taxonomy_term:question_categories, entity:taxonomy_term:recette_categories, entity:taxonomy_term:recette_ingredients, entity:taxonomy_term:recette_niveaux, entity:taxonomy_term:recette_tags, entity:taxonomy_term:recette_types, entity:taxonomy_term:service_tags, entity:taxonomy_vocabulary, entity:tour, entity:user, entity:user_role, entity:webform, entity:webform_submission, entity:webform_submission:concours_fevrier_2018, entity:webform_submission:invitation, entity:webform_submission:mode_de_livraison, entity:webform_submission:passerelle_de_paiement, entity:webform_submission:supprimer_la_boutique, entity:webform_submission:supprimer_le_compte, entity:webform_submission:supprimer_le_groupe, entity:webform_options, entity:workflow, entity:menu_link_content, entity:view, entity:paragraph, entity:paragraph:evenement_programmations, entity:paragraph:itineraire_poi, entity:paragraph:recette_ingredients, entity:paragraph:recette_instructions, entity:paragraphs_type, entity:entity_form_display, entity:entity_view_display, entity:entity_form_mode, entity:entity_view_mode, entity:date_format, entity:base_field_override, entity_reference, field_item:address, field_item:address_zone, field_item:address_country, field_item:comment, field_item:commerce_remote_id, field_item:commerce_plugin_item:commerce_condition, field_item:commerce_plugin_item:commerce_promotion_offer, field_item:commerce_plugin_item:commerce_subscription_type, field_item:commerce_plugin_item:commerce_prorater, field_item:commerce_plugin_item:commerce_shipping_method, field_item:commerce_adjustment, field_item:commerce_price, field_item:commerce_billing_period, field_item:commerce_scheduled_change, field_item:commerce_shipment_item, field_item:datetime, field_item:daterange, field_item:duration, field_item:entity_reference_revisions, field_item:file, field_item:file_uri, field_item:geolocation, field_item:image, field_item:link, field_item:metatag, field_item:office_hours, field_item:list_float, field_item:list_string, field_item:list_integer, field_item:path, field_item:physical_measurement, field_item:physical_dimensions, field_item:redirect_source, field_item:state, field_item:telephone, field_item:text_with_summary, field_item:text_long, field_item:text, field_item:viewsreference, field_item:webform, field_item:yoast_seo, field_item:email, field_item:integer, field_item:float, field_item:uri, field_item:string_long, field_item:decimal, field_item:map, field_item:created, field_item:password, field_item:timestamp, field_item:entity_reference, field_item:boolean, field_item:string, field_item:uuid, field_item:language, field_item:changed, timestamp, language, boolean, timespan, any, language_reference, integer, duration_iso8601, map, email, string, datetime_iso8601, list, float, uri, binary dans Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (ligne 53 de /var/www/www-example-com/web/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).Comment #137
tommiecrawford commentedThe new node is not added as a related entity in groups with the chosen group(select widget) with patch #124. Anyone else also got this issue?
I followed these steps:
1. Go to "Manage Fields" for the content type do you want to add in groups.
2. Add a new field of type Reference > Other.
3. For the option "Type of item to reference" select Content > Group. (Not group content).
4. The option "Allowed number of values" depends on your expected behaviour.
On the next screen select all the group content bundles needed in "REFERENCE TYPE", I'm planning to do an improvement to set them as default value.
5. Go to "Manage Form Display" and select the widget "Group Selector" for the field you just created.
I can see the groups but when i save the node nothing happens in groups.
Comment #138
michfuer commentedCan confirm #136. If you try to create a node with a group config constructed ID that's greater than 32 chars, the error is triggered.
It appears the group module hashes the config ID when it's over the limit
The only related line I see in the stack trace is
Drupal\gcontent_field\Plugin\Field\FieldWidget\GroupSelectorWidget->elementValidate(Array, Object, Array)Should this patch be correcting the plugin ID before passing to Drupal core?
Comment #139
zenimagine commentedThere is another problem with the group field, it can not be used with a relation from a node. This poses problems with views, messages, and tokens. It's not really a field.
Can not go back to the parent group of a node.
Comment #140
esolitos@zenimagine I usually create views if GroupContent instead of Content, because it decreases the amount of JOINS.
But, a part from that, it's definitely possible to go down this path: Node -> GroupContent -> Group -> GroupContent -> Node, and you can access all the fields of each of those entities.
The naming of the relationships is not the best, something like "Content from group content" to access the Node when you have a GroupContent.
BTW: I'm not sure also that your report is related to the current issue.
Comment #141
zenimagine commented@esolitos I opened a new problem https://www.drupal.org/project/group/issues/3056822
Comment #142
jidrone commentedHi Everyone,
Here is a new patch with the following:
Comment #143
michfuer commentedI reviewed the test failures for the patch in #142, and they're all
Error: Call to a member function getBaseFieldDefinitions() on nullAnd appear to be coming from this core update
https://www.drupal.org/project/drupal/issues/3035953
specifically
which is called in
Not sure if the failures should be a blocker for approving this patch since I'd expect other patches to fail similarly. Maybe we need a separate issue to track?
Comment #144
dan_metille commentedI'm having an issue, when editing/creating group content via an Entity Reference field and the Inline Entity Form: the group selector is visible, but group is not saved. For that I have to edit that created referenced node separately and then only I'm able to attribute a group to that node.
I'm using that approach because I'm writing blog post, with some part of them is only visible to group members (the referenced entity). It would be great if I could attribute a group to the referenced entity while editing the 'parent' node and the Inline Entity Form.
Is it possible to fix this?
Comment #145
jidrone commentedI addressed the error on tests mentioned in #143 by creating this new issue #3061353: Replace deprecated EntityManager and add EntityFieldManager in GroupContentViewsData because they are not related to this patch.
Comment #146
michfuer commentedI updated the patch to account for nested Add to Group forms. I tested it with a media entity reference field using the 'Inline entity form - Complex' widget, and was able to successfully add the parent node to a group as well as a new inline media entity.
Comment #147
dwwFinally had a chance to review and test this again. Excited this is getting close!
Our sandbox has fallen behind patch #142, so I'm testing that directly.
NW for:

#90.4a
#90.8
I still find #90.9 clumsy and limited. If we're going to have all the different formatter options, can we have a more powerful/flexible choice for parent group that provides:
? Looks like @anruether agrees in #117. Does that need to be a follow-up feature request? @jidrone's answer in #91.9 doesn't really make sense to me:
But the gcontent_field module and everything it provides only injects itself as a field on content associated with groups (at least in my testing). For example, I don't see any mention of it at:
/admin/group/content/manage/private-group_membership/form-display
I'm confused how this computed field + widget on group content (e.g. events, private pages, etc) can be used to subscribe users to groups?
As it is in #142, the widget's behavior is wildly different depending on what widget you use (more than usual). ;) You get fundamentally different possible target entities, not just different ways to select from among the same set.
Behold:
Autocomplete
Checkboxes
Select
If I try to even use IEF and then visit a private_page entity form, I get WSOD with:
The only one that works at all is Group Selector where the available choices make sense (in both select and autocomplete variants).
(Side nit #147.2: the convention in core / contrib is that this should be 'Group selector' (no 'S', only 's')).
I honestly think this field would be safer if we forced the group selector widget. Everything else (as a form display widget choice for this magic field) seems to not give anyone what they want. How can any of those screenshots possibly be the right UI for a content editor creating private content to add to a group?
Also unaddressed:
#113
#127 and #128
Meanwhile, #146 includes syntax errors, so we can't really review/test it. But if that's a bug, it's unaddressed, too.
Thanks!
-Derek
p.s. Updating the summary for remaining tasks. Let's cross off stuff if we have working patches that address any of it. Thanks! Also hiding a bunch of old files.
Comment #148
dwwFixing minor formatting bug in the summary, adding link to 147.
Comment #149
dwwSome additional NW items:
These could use some help. Something explaining a bit more about what this magic computed field provides, at least for the description. Something like:
description: Defines a field to view and edit the groups that content belong to.
(or something -- better alternatives welcome).
Looks like a typo 'ty pe'.
If $allowed_groups is empty, this gives you an empty select dropdown form element. For example, if a piece of content already belongs to all the possible groups. The form element should disappear once all the groups are gone or none are available.
Thanks!
-Derek
Comment #150
zenimagine commentedHi, I applied the last patch to the module. How to display the parent group of a node in the Message module with Token?
I tested the token below and it does not work :
[message:field_node_reference:entity:group_content:entity:group:title][message:field_node_reference:entity:group_content:entity:group:title]
[message:field_node_reference:entity:group_content:group:title]
[message:field_node_reference:group_content:entity:group:title]
[message:field_node_reference:group_content:group:title]
[message:field_node_reference:entity:group:entity:group:title]
[message:field_node_reference:entity:group:group:title]
[message:field_node_reference:group:entity:group:title]
[message:field_node_reference:group:group:title]
Comment #151
dwwThis fixes everything from #149.
Pushed to the sandbox as commit a20f1ec
Still NW (see summary and #147)
Comment #152
dwwI was in a hurry when I uploaded #151. Left stray garbage in the .info file while fixing #149.1. This patch actually works. ;) Still needs help for all the open points.
Comment #153
zenimagine commented@dww Hi, thanks for the patch, can you integrate the token ? Because currently there is no dean to link the content to the group with the token.
Can not find token of the parent group of a node.
Comment #154
dww@zenimagine: I don't currently need or care about the tokens, so that hasn't been what I've been testing and fixing. It's possible I fixed it "on accident" by correcting the typo I saw in #149.2 since that was in
gcontent_field_token_info().I just added #150 to the summary for remaining tasks. Please test patch #152. If it's now working, please cross off #150 from the summary as complete (wrapping in
<del>tags like the others). Otherwise, someone who cares about the tokens will have to debug this and fix it (or document how it works if it's already working).Thanks/sorry,
-Derek
p.s. Note to committers: d.o's issue credit heuristics think I should be the author of this patch. Definitely not. ;) Please use @jidrone as the author. Thanks!
Comment #155
dwwFixed #127 and #128, pushed to the sandbox as commit 6cf1bfb34ed. I think this should pass on the default PHP 5 now...
Interdiffs against #152 (to see the 3 fixes from @catch) and against #142 (to see everything "I" fixed since @jidrone's last patch).
Comment #156
dwwWhoops, I missed the point in #117 that #85 / #109 is still broken. Added those to the summary's remaining tasks. (Another feature / aspect I don't care about, so hopefully someone with multiple group types can take a look). ;)
Cheers,
-Derek
Comment #157
geek-merlinAs of #146, while that patch might have been messed up, the interdiff seems to make sense. It drops the assumption that we're at the form root, else no changes. So someone(tm) might want to integrate that interdiff. Cool to see the ball rolling, kudos derek and everyone!
Comment #158
dww@axel.rutz re: #157 -- oh yeah, good point. The syntax errors are just the PHP7 null coalesce operators (now fixed) so this should pass on both PHP5 and PHP7. Integrated patch #146, fixed a very minor code style bug in it, pushed to the sandbox, crossed off from the summary. I did *not* test the case mentioned of using IEF.
We almost certainly need tests for at least some of this functionality (see #90.10). Tagging and adding to the summary.
Cheers,
-Derek
Comment #159
zenimagine commentedI tested the following Token with patch #158 :
[message:field_node_reference:entity:group_content:group:title]
[message:field_node_reference:entity:group_content:entity:group:entity:title]
[message:field_node_reference:entity:group_content:entity:group:title]
None work. In the first patch, tokens worked.
Comment #160
dwwThis fixes #90.9 (see also #117 and #147).
I started down the road of making the single ParentGroupFormatter class support more settings to determine what kind of formatter you want. Then I realized the whole thing was extending the EntityReferenceEntityFormatter and saw how much code I'd have to duplicate from the other EntityReference*Formatter classes to support the other display types (label + ID).
So, then I split
ParentGroupFormatterinto 3 formatter classes,ParentGroup(Entity|Id|Label)Formatter, each extending from the correspondingEntityReference*Formatter. I put the magic fromgetEntitiesToView()into a trait that's shared among all 3 (can't use a base class since each formatter needs to extend a differentEntityReference*Formatterclass).Given the shared trait, the 3 formatter classes are now very simple. Only
ParentGroupEntityFormatterneeds to override any parent methods (to get the right view_mode options for groups). The other two are exactly the parent formatter classes, with the overriddengetEntitiesToView()from the trait.The trait itself might want a rename (currently "
ParentGroupFormatterGetEntitiesTrait").Otherwise, we now have all the display flexibility we might want for this (especially
ParentGroupLabelFormatterwith an option to link to the group or not).Cheers,
-Derek
Comment #161
dwwThis fixes #147.2 (s/Group Selector/Group selector/).
Note: the fails on #158 for 8.8.x core are due to #3061353: Replace deprecated EntityManager and add EntityFieldManager in GroupContentViewsData not this patch. We shouldn't test against 8.8.x until #3061353 is fixed.
Comment #162
dwwFixes code style bugs being warned about in https://www.drupal.org/pift-ci-job/1338423
However, I really don't like that modules/gcontent_field/css/gcontent-field.admin.css targets everything first via a
.jsselector. I think we should remove that, although I haven't actually tried it, yet. Maybe @jidrone can comment on why the patch defines those styles in that way. Adding this to the summary as a @todo.Comment #163
dwwBah, missed a few more code style problems I had introduced in #160.
Comment #164
anruetherThanks for your work, Derek!
I tested #163 and saw this if you add a regular group reference field after enabling gcontent_field:
Widget and Formatter of regular group reference fields are identical to those of the new field. This leads to WSOD when for the reference field...
- in the widget, you select
Group Selector- in the formatter, you select
Parent Group ...(for a group reference field this option doesn't make any sense anyways)I guess those settings shouldn't be there in the first place ?! Let me know if you need the full backtrace:
Error: Call to undefined method Drupal\group\Entity\Group::getGroup() in Drupal\gcontent_field\Plugin\Field\FieldFormatter\ParentGroupLabelFormatter->getEntitiesToView() (line 23 of /var/www/html/web/modules/contrib/group/modules/gcontent_field/src/Plugin/Field/FieldFormatter/ParentGroupFormatterGetEntitiesTrait.php)Comment #166
dww@anruether re: #164: Ugh, yeah. I see exactly what you mean. This is a Big Problem(tm) with the approach in this patch. The custom computed field here is "just" an entity_reference field type. So, the formatters and widget are configured to apply to that field type, and therefore they show up *everywhere* in the field_ui when you're touching any kind of entity_reference field. :(
I think the Right Way(tm) to deal with this is that instead of just defining our own custom GcontentFieldItemList class and configuring this magic entity_reference field to use it, we should really define a new, custom field *type* for all this. It should simply extend entity_reference, but have a different field type ID. Then, the custom formatters and widget will target the custom field type. That way, these magic formatters and widget won't "leak" out into other entity reference types.
That's +1000 from me, but I fear @jidrone won't like it, since it'd mean we'd completely resolve #90.9 in my favor: namely, that the "other" ways to format these group_content entities wouldn't keep "working" (if you call the screenshots in #147 "working"). ;)
Short of that, I don't know of any way to hide the formatter(s) and widget(s) from the "wrong" kinds of entity_reference fields. We only get a plugin annotation, and at that level, all we have to work with is a specific field type. We don't get to test properties of the entity the field is attached to, etc. Maybe someone else knows a way around this.
@joachim re: #113:
I don't see how. There's no call to
gcontent_field_get_entity_types()insidegcontent_field_get_entity_types(). The code you quoted is insidegcontent_field_entity_base_field_info(), which callsgcontent_field_get_entity_types()which does a bunch of stuff but I don't see how anything in there would trigger another call togcontent_field_entity_base_field_info().Crossing #113 off the list of remaining tasks. @joachim please clarify if I'm misunderstanding your concern.
@zenimagine re #165 - nope, I didn't change the field name. But I *did* change the IDs for the field formatter, so existing sites running the patch will have to re-save their 'Manage display' world on any group-enabled content types to get the formatters working again.
Comment #167
zenimagine commented@dww Yes, thank you indeed, you have to save the display again. I was too fast in my comment.
But concerning Tokens, the last patch does not correct. With the Message module, I created a message template for the new nodes and I was unable to trace the name of the parent group.
Comment #168
dww@zenimagine re: #167: Yup. The brokenness of tokens is: a) already in the summary of remaining tasks, b) something I already said I don't care about (or more accurately, the project I'm currently working on that needs this functionality doesn't care about) and therefore it's not something I'm going to be able to fix for you. Sorry.
Meanwhile, cleaning up some other aspects of the summary that either had typos/grammar bugs, or were out-of-date based on recent changes.
Comment #169
geek-merlin@dww #166;
> The custom computed field here is "just" an entity_reference field type. So, the formatters and widget are configured to apply to that field type, and therefore they show up *everywhere* in the field_ui when you're touching any kind of entity_reference field. :(
I did not fully grok the problem, but i guess a solution without making up a new field type ID might (or might not) come from \Drupal\Core\Field\WidgetBase::isApplicable / \Drupal\Core\Field\FormatterBase::isApplicable ;-)
Comment #170
dwwRe: #169: Cool, that sorta helps. ;) This takes advantage of that method to hide the custom formatters and widget unless the field is our custom computed field.
However, I still think our own (unique) field type would be better, since:
a) This patch is a hack, hard-coding the field name to 'group_content' and type (entity_reference). I don't think there's a safe way to really know that's what our computed field is called, and hard-coding the field name like this seems like a major hack. However, I don't know how else to identify our field since it's re-using 'entity_reference' type.
b) While this hides the custom formatters and widget from other entity_reference fields (yay -- solves #164), all the (IMHO totally bogus -- see #147) alternate widgets and formatters for entity_reference fields still appear when configuring the group_content computed field. @jidrone probably thinks that's a feature. I consider it a bug. ;)
Anyway, it's here for consideration. I'm not sold this is the right solution, but it's better than nothing.
Comment #171
jonathanshawMaybe there's a compromise on #90.9:
go for a custom field type, but then opt in to the formatters / widgets that could be useful to someone with the right settings and config, but not to those that cannot be made useful without custom development work no matter how you configure them.
Comment #172
jidrone commentedHi everyone,
Yes, I think we can go for a custom field type, I'm going to explain better why a Rendered entity formatter makes sense:
Any content entity type can be added as Group Content is the needed plugin is provided, out of the box the group module has support for Users and Nodes.
The field provided by this module detects all entity types with support for groups and adds the field to them.
Here is where the formatter can be useful:
Comment #173
dww@jidrone re: #172: Thanks for the reply. Indeed, I recently discovered that the field shows up directly on user entities, letting you manage group memberships while editing a user. At #147 I foolishly thought it would be on the group content relationship entities (which didn't make sense):
...but I hadn't noticed the field on users (yet). Given that, yes, I see there could be reasons to show the relationship entities (the membership itself, including the group roles, etc) not just the parent group. I've been looking at this issue entirely from the content side, not users.
So yeah, we probably need to retain the "raw" entity reference formatters for the new field type, although arguably we can get rid of the other widgets since I don't see how the other widgets help, even for the user case.
If we go with a new custom field type, probably the cleanest way to propagate the other entity reference formatters to them is to have trivial classes that extend the core formatter classes, but use different plugin IDs and target our custom field type. More or less like the new formatters I added in #160, only without needing to use the trait to override
getEntitiesToView().Anyway, I hope you get a chance to work on some of the remaining items, since I'm basically out of time for right now, and will be busy at least for the next 3+ weeks.
Thanks!
-Derek
Comment #174
geek-merlin> If we go with a new custom field type, probably the cleanest way to propagate the other entity reference formatters to them is to have trivial classes that extend the core formatter classes, but use different plugin IDs and target our custom field type.
hook_field_widget_info_alter / hook_field_formatter_info_alter ?
Comment #175
jidrone commentedHi everyone,
Latest commit to https://www.drupal.org/sandbox/dww/3045926, has the new field type approach for you to test, with the hook_field_formatter_info_alter.
Comment #176
dww@jidrone re: #175: Thanks! Looks good. Here's the latest in patch form for anyone not using the sandbox (which is a good idea -- patching the latest group is better than relying on the sandbox, since I'm not keeping the sandbox sync'ed up with the rest of group (99% of what we're doing is in a whole new module)). Haven't had a chance to test yet, but the commit/interdiff looks right. ;)
One question is if the
hook_field_formatter_info_alter()implementation should inject thegroup_contentfield type into the available field types for theentity_reference_entity_idandentity_reference_labelformatters, too. IMHO, seems like it should.Otherwise, I think we're done with the concerns in #164 (and #166) so I'm crossing those off the list in the summary.
Progress! :)
Cheers,
-Derek
Comment #177
anruetherregarding my comments in #109:
1. The Group selection on node/add forms needs the "Relationship: Add entity relation" permission, although the "Entity: Add content entities" permission should suffice"Entity: Add content entities" is enough with patch from #1762. a) Node add form: If the user does have the permission to remove a relation, he/she cannot change the group after setting it once (before saving the node form). Seeing how 2b behaves this looks like a bug. I would even say, the user should be able to change the group as long as the node hasn't been created no matter if he has any permission to edit/remove the relation.
b) and c) are just for background info, no issue here:
b) (Node edit form: If the user does have the permission to remove a relation, he/she can remove the relation and add the node to a new group. This works as expected.)
c) (Node edit form: If the user does have a "Relationship: Edit .." permission, he/she can see an edit button. On clicking it a collapse button appears, after clicking that the edit button appears with the message "You have unsaved changes on this item.". On this roundtrip I cannot change the group setting, which is correctly indicated by the "You are not allowed to remove this item." however if there were any fields on the relation, those could be editable. So, I assume this works as expected as well.)
3. It only works with the default group type, not with any custom group type. There I'm getting a similar error as #77cannot reproduce with patch from #176Updating the summary accordingly.
Comment #178
anruetherComment #179
jidrone commentedFixed tokens and removed .js class from gcontent-field.admin.css because is not really needed for it to work.
Also updated summary.
Comment #180
jidrone commentedI forgot the patch.
Comment #181
jidrone commentedRegarding to #90.8 I think the problem was a wrong message.
After patch #91 the behavior is the following:
Member of groups without permissions (existing group relations)

Member of groups without permissions (new node)

Do you think we need to remove the field when adding a new node?
Comment #182
zenimagine commented@jidrone Thanks, the tokens works
Comment #183
damienmckennaI think it'd be also useful to add some documentation, even a simple README.txt file with a paragraph or two explaining the intended use scenario would be incredibly helpful.
Comment #184
damienmckennaI tried out patch #180, set up the field on a content type that pointed to the "group" content entity, but get this AJAX error when I click the "Add to group" button:
Comment #185
damienmckennaFor what it's worth, I tried both field widgets (select, autocomplete) and they both gave the error from #184.
Comment #186
michelleEDIT: Nevermind this. It must have been something in our custom code affecting it. The lead on the project was able to get it working on his branch.
I am not having any luck getting the patch in #180 to work. I added the new field to the basic page type and the went to the "all entities" tab on the group and tried to add an existing basic page. When I do that, I get a fatal error in this code:
$gcontent_entity = $item->entity; doesn't work because $item->entity returns null. That gets a fatal error in $gcontent_entity->id(); when it's expecting it to be an object. I tried changing that to getEntity() instead but that gets the basic page node, which doesn't seem to be what is wanted there. I wasn't able to figure out where "entity" was supposed to be added so am having no luck getting past this.
Comment #187
meecect commentedIs it possible to configure this field as _not_ readonly? Like so:
->setReadOnly(FALSE)
in gcontent_field_entity_base_field_info?
There seems to still be some confusing discusison around what that property is to mean. I saw some talk of it here:
https://www.drupal.org/project/drupal/issues/2350429
The reason I would like it to not be readonly is that I am piggy-backing on top of this module to create a group content target plugin for the Feeds module. When the field is set to readonly, the Groups field does not show up as a target that can be configured in the Feed Target Mappings.
There is more discussion of that feeds target here:
https://www.drupal.org/project/group/issues/2991293
Comment #188
damienmckennaOk, upon further testing I've found that it does actually work.
However, I have other concerns:
Comment #189
joe huggansTrying to test this new feature but encountering an error, a warning and several notices when creating a field. Steps to reproduce
- Clean D8 installation
- Install Group module
- Apply patch
- Create group type
- Add "Groups" field to group type referencing content of "basic page"
Error: Call to a member function uuid() on null in Drupal\Core\Field\EntityReferenceFieldItemList->defaultValuesFormSubmit() (line 126 of /var/www/html/session-group-ui/core/lib/Drupal/Core/Field/EntityReferenceFieldItemList.php) #0 /var/www/html/session-group-ui/core/modules/field_ui/src/Form/FieldConfigEditForm.php(197): Drupal\Core\Field\EntityReferenceFieldItemList->defaultValuesFormSubmit(Array, Array, Object(Drupal\Core\Form\FormState)) #1 [internal function]: Drupal\field_ui\Form\FieldConfigEditForm->submitForm(Array, Object(Drupal\Core\Form\FormState)) #2 /var/www/html/session-group-ui/core/lib/Drupal/Core/Form/FormSubmitter.php(111): call_user_func_array(Array, Array) #3 /var/www/html/session-group-ui/core/lib/Drupal/Core/Form/FormSubmitter.php(51): Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object(Drupal\Core\Form\FormState)) #4 /var/www/html/session-group-ui/core/lib/Drupal/Core/Form/FormBuilder.php(590): Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object(Drupal\Core\Form\FormState)) #5 /var/www/html/session-group-ui/core/lib/Drupal/Core/Form/FormBuilder.php(319): Drupal\Core\Form\FormBuilder->processForm('field_config_ed...', Array, Object(Drupal\Core\Form\FormState)) #6 /var/www/html/session-group-ui/core/lib/Drupal/Core/Controller/FormController.php(93): Drupal\Core\Form\FormBuilder->buildForm('field_config_ed...', Object(Drupal\Core\Form\FormState)) #7 [internal function]: Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch)) #8 /var/www/html/session-group-ui/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array) #9 /var/www/html/session-group-ui/core/lib/Drupal/Core/Render/Renderer.php(582): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #10 /var/www/html/session-group-ui/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure)) #11 /var/www/html/session-group-ui/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) #12 /var/www/html/session-group-ui/vendor/symfony/http-kernel/HttpKernel.php(151): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #13 /var/www/html/session-group-ui/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) #14 /var/www/html/session-group-ui/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #15 /var/www/html/session-group-ui/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #16 /var/www/html/session-group-ui/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #17 /var/www/html/session-group-ui/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true) #18 /var/www/html/session-group-ui/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #19 /var/www/html/session-group-ui/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #20 /var/www/html/session-group-ui/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #21 /var/www/html/session-group-ui/core/lib/Drupal/Core/DrupalKernel.php(693): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #22 /var/www/html/session-group-ui/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #23 {main}.
Comment #190
jazzfiction commented1) Regarding #184, also I found that you can't create a field pointed to 'Group' content entity, but you must use the preexisting field found in Manage from display. I also got the same error. This confused me at first until I saw the preexisting field. I think if the user is suppose to use the preexisting field, then the 'Group' entity needs to be removed from the entity list so you can't create a custom field with it. Content Moderation's 'Moderation State' field is an example of this.
2) In testing patch from #180, I found that there is a permission issue. When a member of a group has been given permission to edit or add relations via permissions given by a role in the 'Advanced Outsider Permissions', a warning pops-up that states 'This entity (node: 88) cannot be referenced.' Only when I add the user to a group role with the same permissions does this warning go away.
The first screen shot is the permissions that I set for both outsider and group roles. The second screen shot shows the errors with just outsider permissions. The third is the same content item with the group role applied.
Comment #191
jazzfiction commentedWhen I uninstalled the module, when it removed the Group entity from the 'Manage Form Display' tab, it also disabled everything that wasn't default for a content type, and removed my field groups. I had to recreate my field groups, move everything back into place, and change back all of the field settings.
Comment #192
damienmckennaFWIW because of the extra layer of abstraction required for Group, we've switched to using OG for this sort of functionality on new projects as it's a much simpler system, and this rudimentary requirement works as expected.
Comment #193
meecect commented@DamienMcKenna, we did the same here.
Comment #194
psf_ commentedIf we are using field group and we have a group with the name "group_content" the field in the patch is not visible.
Comment #195
joshuami@DamienMcKenna, can you say more about your use of OG for this purpose? I have been following OG development for D8 and the last release still does not have have a UI for managing roles and permissions within a group. Lack of roles and permission prevents us from using it, but I want to make sure I'm not missing something.
One thing I like about the approach is issue is taking is that you can display the form for the group content as part of adding the group. This means we could add fields for featuring content on a group for a period of time on the group content entity rather than on the content node itself. That flexibility is a nice feature.
I have the patch from #180 running successfully against Drupal 8.6.7 and Group 8.x-1.0-rc4. I can add content to multiple groups fairly easy, but there is a small gotcha in that the field allows you to override the cardinality in the content plugin settings. So you have the ability to say it should only have one group in your plugin config and allow it to have multiple in the field settings. The field settings override the group plugin settings on the node edit form only.
The need to click "add group" is going to be problematic for some use cases, but for migration I think we might be able to run two scripts, one to create the content and then a second to create the group content nodes adding the content to the group.
@kristiaanvandeneynde, what are the chances of this approach making it into the 1.0 release of Group?
Comment #196
dww@jidrone re: #181:
No, I think we should hide the parts of "the field" for users that don't have permission to use them. Re-quoting #90.8:
Users should only see the parts of the widget that they can use. E.g. anyone can see if a given node belongs to any of the groups they're members of, but only users with sufficient privs should see the stuff about adding a node to new groups, etc. If I'm not allowed to remove it, I don't need a huge yellow warning. I just need to see the group names without any operation buttons. Hope that clarifies the intention of #90.8
New UI ideas/points:
#196.1: The widget should really render as a "details" container ("fieldset" in D7 and before), e.g. like entity_browser does, since it's got a bunch of related form elements.
#196.2: Not clear why the widget is using tabledrag. What does the order of groups on a node edit form impact? Nothing, right? We don't save those as deltas with the computed field or anything, right?
@DamienMcKenna re: #183: Agreed, some docs would help. Tagging as such.
@meecect re: #187: Hrm, not sure. I don't yet fully grok the implications of readonly or not.
@jazzfiction re: #190.1: Yup, that answers #189.
re: #190.2 and #191: Added to summary as bugs to fix. Good finds.
@psf_ re: #194: Heh, yeah. Not exactly sure what to do about that. :/ Namespace collisions waiting to happen in all this. Added to summary.
@joshuami re: #195:
- Added cardinality bug to summary.
- re: 8.x-1.0: Sadly, given the long list of remaining tasks in the summary, I highly doubt this will make it into 8.x-1.0. However, since the vast bulk of this is an entirely separate sub module that sites have to opt-in to, I think it'd be a strong candidate for 8.x-1.1 if I understand @kristiaanvandeneynde right about release management and BC concerns from some other issues (sorry, don't have the links).
@all re: OG vs. group -- can we have that discussion elsewhere? It's off topic. Neither project page mentions the other, I don't know of any good comparisons, etc. Seems the community needs to write it/them. Can we do that elsewhere, like at #1457506: Differences between OG and group module, text for project page.? This issue is already huge, in danger of becoming totally un-readable. Please only post here if you're fixing the existing remaining tasks or have to add more to the list (in which case, please update the summary as you do).
Thanks!
-Derek
Comment #197
jonathanshawIsn't #190.1 (which explains #189) also a to-do?
Comment #198
dww@jonathanshaw re: #197: Oh, whoops, I missed that there was a proposal at the end of #190.1:
However, I don't want to add that to the summary (yet), since I don't really understand the proposal. What does "the 'Group' entity needs to be removed from the entity list" mean? What list of entities? You mean entities available for use via an entity_reference field? No way, we can't remove that. Folks might want to use an entity_reference field pointing to group entities (or even group_content entities) for all sorts of other things. This issue is not a complete replacement for all possible fields that touch group-esque things. If a site builder actually tries to use a regular entity_reference field for this functionality instead of the field provided by the gcontent_field module, I'm not sure there's much this patch can do about it to help them (other than provide good docs, as already tagged/listed in the summary).
#190.1, as written, isn't actionable for the summary, so I'm leaving it off. If someone can clarify a legitimate (specific) change we should make to improve the UX/DX of this whole mess, let's hear it.
Thanks!
-Derek
Comment #199
joshuamiRegarding 196.2 (tabledrag), it doesn't seem to save the order on node save. I could see the value of ordering the group relations. We plan to use this on news that can be posted on behalf of multiple offices within a government organization. There are often times when the "primary" group would be listed first in a list of groups that were all associated to the news.
It would be nice if the first group in that order was associated with the group tokens for that content. It would make path aliasing and breadcrumbing the content a bit more consistent.
Comment #200
dwwRe: #199: I have no idea where/how you'd store those deltas. This isn't a real entity reference field. It's computed based on the existence of other (group_content) entities. Those entities don't have any notion of weight/delta/etc, so we'd have to add them. #NeedsFollowup. ;) Or, we need to actually make this a real field. But I don't see any way to have weights/deltas matter given any of the current architecture, and it seems way out of scope to try to add all that to this already huge effort. I vote we remove tabledrag (since the weights are currently meaningless) and convert it back to tabledrag if/when there's somewhere to persistently store these weights.
Comment #201
michelleIs there a reason it isn't a real field? It seems like that would make a lot of things easier. Perhaps just put the field machine name in config somewhere so it knows what field it needs to use for the syncing. Then you'd have all the benefits that go along with real fields like being able to use Views.
Comment #202
joshuami@Michelle, the biggest reason for using a computed field is the architectural model of Group. Group stores the relationship between an entity and its group in a group content entity. That means the relationship isn't stored in the content entity itself.
If we added all of this functionality into an actual field, then we would have to synchronize any changes between the field and the group content entities. That is a lot of overhead. We did this on a project and were not very happy with the result. It required a lot of custom code to update both the content entity and the group content entity on any change from either direction.
By using a computed field, we are changing the group content entities themselves from within the content entity form.
@dww, I hear you about the deltas for group content entities. I agree it makes the scope a little more ungainly, but without some sense of order for the group content entities against the content entity, there is no meaning to the [node:groups] tokens. In those tokens, added by this patch, there is the notion of first and last in the list, but neither can really be used because first and last changes with every new group content entity created from this field.
I'm going to add a note to https://www.drupal.org/project/group/issues/2774827 to see if the work to add group tokens could consider the issue of multiple group content entities and their relative order. It might be something like adding a weight field to the group content entity so that if a content entity is related to multiple group content entities it can sort them.
Comment #203
artatac commentedGroup_notify also shows the groups a node is associated with in the edit screen see
https://www.drupal.org/project/group_notify/issues/3076248#comment-13234219
Comment #204
tim.clifford commentedHi all, great work so far on this submodule.
I've added the new 'Groups' field to an article content type and installed that as a group node (group_node-article) within a group.
However, when attempting to save this (with plugin group_node:article) with the new 'Add to Group' widget, an exception is thrown as the GroupContent entity doesn't exist yet.
The website encountered an unexpected error. Please try again later.</br></br><em class="placeholder">Drupal\Core\Entity\EntityStorageException</em>: Cannot load GroupContent entities for an unsaved entity. in <em class="placeholder">Drupal\group\Entity\Storage\GroupContentStorage->loadByEntity()</em> (line <em class="placeholder">84</em> of <em class="placeholder">modules/contrib/group/src/Entity/Storage/GroupContentStorage.php</em>). <pre class="backtrace">Drupal\group\Entity\GroupContent::loadByEntity(Object) (Line: 72)So, I commented out this bit so the form would load.
The problem of course now is that the 'target_id' is missing on save for the new Group Content Entity which would have been added by this:
Does anyone else see this issue? Is there a way to temporarily store an id which would then later be updated when saving the fields for the Group Content entity (i.e. the relationship part)?
Comment #205
kevin w commentedHow to set the default value dynamically?
Thank you for the great patch! We have a requirement to set the default group dynamically inside a entity browser form widget. When I tried to set the widget state values
selected_groupandselected_bundlein the form_alter hook and call$form_state->setRebuild(), the widget doesn't get rebuilt with the new default group. Is it possible to set the widget state beforeGroupSelectorWidget::formMultipleElements()is invoked without changing code inGroupSelectorWidget? Thanks!Comment #206
dianacastillo commenteddidnt work at first but then i reinstalled the group module and repatched and seems to work now
Comment #207
michelle@dianacastillo It's been a while since I looked at this but I believe you aren't actually supposed to add the field normally. That tripped me up as well. It's not a real field but rather some sort of fake pseudo-field that gets automatically added? Someone can probably explain that better than I can but I wanted to give you a quick answer to at least point you in the direction of the problem. :)
Comment #208
dianacastillo commented@michelle you are right it gets automatically added but you have to go to the manage form display of the content type and make it enabled to see it in the form
Comment #209
michelle@dianacastillo : Ah, sorry, I misunderstood what you did. Glad you got it working.
Side note, I wish d.o noted when a comment is edited. This exchange looks confusing because comment #206 was completely different when I responded to it. LOL
Comment #210
kristiaanvandeneyndeI'm a bit (actually, very) swamped right now, but I'd like to see this UX improvement go in.
Here's the minimum it would require:
The goal is to not introduce extra storage (fields), but rather use the existing data architecture, query access handlers, etc. The only thing that needs to happen is a form alter, a submit handler and an extra boolean on content plugins to enable/disable this behavior.
I will be on Slack for the next few weeks, so ping me (kristaanvde) there if you want to work on this and need input. I'll try to get back to you in a timely fashion. I'm usually online between 10AM and 5PM CET.
Comment #211
kristiaanvandeneyndeIf it makes your life easier, we could start with an assignment-only patch (i.e.: add to group only) and work our way through removing entities from groups on their edit forms in a follow-up.
Comment #212
dalra commentedComment #213
dalra commentedThe same needs to be done for adding content to groups.
#2771065: Group Node: Only authors should be able to create Gnodes for their nodes and #9.
Comment #214
dianacastillo commentedhas anyone yet figured out a way to let a user only add groups he is a member of? I see that if he is not a member he gets the message "you cannot remove this item" because I did not give them permissions to "edit others content"
is there any way to make the select only show groups the person who is adding belongs to ?
Comment #215
arnaud-brugnon commentedPlease, dont use private method.
With #179, it works for me expect that i cannot change my group list (because getAllowedGroups is private).
I replace all private method with protected method (so much better to override)
Comment #216
arnaud-brugnon commentedComment #217
arnaud-brugnon commentedSorry, wrong patch extension (stupid laptop)
Comment #218
moshe weitzman commentedThe part that I'm looking forward is actually the computed field part so that search_api integrates without any custom code (for example). Should we spin off a new issue for that? Or maybe thats simply not desired?
Comment #219
moshe weitzman commentedOr maybe the computed field work should resume at #2718195: Add a computed field for entity's group(s)?
Comment #220
avpadernoComment #221
geek-merlin@moshe: ~100 comments ago we consolidated the 3 issues into this one (to rule them all), using a computed field approach.
Comment #222
zenimagine commented#217 works well for me
Comment #223
quentin massez commentedHello,
Thanks for the work !
I used the patch in #217, it also worked for me on my already installed sites.
But when I tried to install a new local site, I had a problem on a custom entity type defined by another module.
"The entity type doesn't exist".
Here is the new patch to avoid this issue on installation.
Comment #224
avpadernoComment #225
plousia commentedNeither #217 nor #223 are working for me. The site is on 8.8.1 and I'm logged in as the root user. I've tried different Group permissions, but still no dice. I add a Groups field to the content type and set it to reference Groups. I can see the group names in the autocomplete and select them, but when I choose one and click "add to group" it continues saying "Not yet added to groups." When I save the node and re-edit, the field is empty.
I am using Workflow module (contrib, not core) and the "save" action is being provided by Workflow (different form submit buttons to save the node in different workflow states). That doesn't explain why it doesn't seem to register the group add on the node edit form, though. Am I missing something?
EDIT: I did get this working, though can't remember what the issue was.
Comment #226
roam2345 commentedComment #227
the_glitch commentedPatch in comment #180 fails to apply
(group-field_to_view_and_edit_content_groups-2813405-179.patch)
Comment #228
cesardmoro commentedPatch #223 not working on latest dev module
$ git apply --verbose ./group/group-field_to_view_and_edit_content_groups-2813405-223.patch.txt
Skipped patch 'src/Form/GroupSettingsForm.php'.
Skipped patch 'src/Plugin/GroupContentEnablerManager.php'.
Skipped patch 'src/Plugin/GroupContentEnablerManagerInterface.php'.
Checking patch modules/gcontent_field/config/install/gcontent_field.settings.yml...
Checking patch modules/gcontent_field/css/gcontent-field.admin.css...
Checking patch modules/gcontent_field/gcontent_field.info.yml...
Checking patch modules/gcontent_field/gcontent_field.libraries.yml...
Checking patch modules/gcontent_field/gcontent_field.module...
Checking patch modules/gcontent_field/gcontent_field.tokens.inc...
Checking patch modules/gcontent_field/src/Element/GroupAutocomplete.php...
Checking patch modules/gcontent_field/src/Field/GcontentFieldItemList.php...
Checking patch modules/gcontent_field/src/Plugin/EntityReferenceSelection/GroupContentSelection.php...
Checking patch modules/gcontent_field/src/Plugin/Field/FieldFormatter/ParentGroupEntityFormatter.php...
Checking patch modules/gcontent_field/src/Plugin/Field/FieldFormatter/ParentGroupFormatterTrait.php...
Checking patch modules/gcontent_field/src/Plugin/Field/FieldFormatter/ParentGroupIdFormatter.php...
Checking patch modules/gcontent_field/src/Plugin/Field/FieldFormatter/ParentGroupLabelFormatter.php...
Checking patch modules/gcontent_field/src/Plugin/Field/FieldType/GroupContentItem.php...
Checking patch modules/gcontent_field/src/Plugin/Field/FieldWidget/GroupSelectorWidget.php...
Checking patch modules/gcontent_field/templates/gc-field-dropbutton-wrapper.html.twig...
Applied patch modules/gcontent_field/config/install/gcontent_field.settings.yml cleanly.
Applied patch modules/gcontent_field/css/gcontent-field.admin.css cleanly.
Applied patch modules/gcontent_field/gcontent_field.info.yml cleanly.
Applied patch modules/gcontent_field/gcontent_field.libraries.yml cleanly.
Applied patch modules/gcontent_field/gcontent_field.module cleanly.
Applied patch modules/gcontent_field/gcontent_field.tokens.inc cleanly.
Applied patch modules/gcontent_field/src/Element/GroupAutocomplete.php cleanly.
Applied patch modules/gcontent_field/src/Field/GcontentFieldItemList.php cleanly.
Applied patch modules/gcontent_field/src/Plugin/EntityReferenceSelection/GroupContentSelection.php cleanly.
Applied patch modules/gcontent_field/src/Plugin/Field/FieldFormatter/ParentGroupEntityFormatter.php cleanly.
Applied patch modules/gcontent_field/src/Plugin/Field/FieldFormatter/ParentGroupFormatterTrait.php cleanly.
Applied patch modules/gcontent_field/src/Plugin/Field/FieldFormatter/ParentGroupIdFormatter.php cleanly.
Applied patch modules/gcontent_field/src/Plugin/Field/FieldFormatter/ParentGroupLabelFormatter.php cleanly.
Applied patch modules/gcontent_field/src/Plugin/Field/FieldType/GroupContentItem.php cleanly.
Applied patch modules/gcontent_field/src/Plugin/Field/FieldWidget/GroupSelectorWidget.php cleanly.
Applied patch modules/gcontent_field/templates/gc-field-dropbutton-wrapper.html.twig cleanly.
Comment #229
dwkitchen commentedWas going to re-roll this patch but it is applying cleanly today.
Also, add it works adding the correct field to group content on Group 8.x-dev
Comment #230
jonathanshawI doubt this can be RTBC given #210?
Comment #231
dwwIndeed, NW for #210 plus the long list of remaining tasks in the issue summary.
However, I asked @kristiaanvandeneynde in Slack about this issue. In most cases, he's encouraging people to spin up standalone module projects for big features like this (see #2984315-56: Media enabler).
From our Slack exchange:
My opinion:
Open question: where should we move this?
Any strong opinions?
Anyone else want to be a co-maintainer from the start? @jidrone? ;) Others?
Thanks!
-Derek
Comment #232
jonathanshaw+1, +1, and a hundred times +1.
Another advantage of 3 is that it makes migration of the field back into the module easy also. I'd make forwards comparability the main criterion for choosing a name.
Comment #233
esolitosAny solution which reduces the amount patches we've applied it's definitely very welcome. :)
The only note is: I'm ok with any name, however if we move away from
gcontent_fieldwe should try as hard as possible to provide a upgrade path from the current name, because breaking sites it's not nice, and even less fun it's fixing them :DComment #234
dwwRe:
"gcontent_field" isn't any easier or harder to move back into Group core. The existing sub modules are "gnode" and "grolesync". There's no specific requirement on what the submodules are called, and even if there was, "gcontent_field" wouldn't necessarily be following it. ;) I don't see how "forwards comparability" favors any of the 3 choices. Ultimately, @kristiaanvandeneynde would have to weigh in on that, but I don't think it matters (beyond personal preference).
Re:
Yeah, that's more of a concern. That's a fairly good reason to keep the current name. Also saves a few hours of work renaming everything in the code. ;) I'm leaning towards that, simply out of laziness. But this seems like our one and only chance to give this code a more proper name, so I wanted to get some input before unilaterally letting pragmatic laziness make the decision for me.
Thanks,
-Derek
Comment #235
kristiaanvandeneyndeIf it helps: I'm trying to get rid of the gnode-like naming pattern. It's something I was forced to use for D7 because of hooks colliding all over the place (especially hook_group_permission vs hook_permission).
Try coming up with names that make sense, but avoid the pattern group_<ENTITY_TYPE_ID>, because those will keep causing issues until core finally gets rid of hooks altogether:
Otherwise you get confusion about group_node_access etc.: Is it hook_node_access() for Group or hook_access() for Group Node?
Comment #236
dww@kristiaanvandeneynde: Yes, that is very helpful. It's a clear vote against #231.3, with other useful info and background. Thanks!
1. "group_content_field" should be totally fine, since "content" isn't an entity type (yet!). Maybe someone would do that in contrib/custom?
2. "entity_group_field" seems extremely safe from hook collision woes. But would it be weird to have a group core submodule that starts its namespace with "entity" not "group"?
3. "gcontent_field" is easy but you're trying to phase that out.
4. What about "group_entity_field"? Is that too generic? Misleading?
@kristiaanvandeneynde if you'd be willing to state a clear preference, it'd speed up this decision dramatically. ;)
Thanks!
-Derek
Comment #237
jonathanshaw'group_contentfield' seems good to me.
Comment #238
maxilein commentedI like 'group_contentfield'.
Comment #239
jidrone commentedHi everyone,
I initially named the module "gcontent_field" to be consistent with other submodules, but now that we are finding a new name I like group_content_field.
I want to be a co-maintainer and I'm organizing my time to be able to do so when we get an agreement with the name.
Comment #240
the_glitch commented.
Comment #241
kristiaanvandeneyndeAsk yourself what the field does: It attaches to an entity and shows that entity's groups. So I'd say go with entitygroupfield or entity_group_field, although the latter is risky due to field hooks.
Comment #242
dwwHello world:
https://www.drupal.org/project/entitygroupfield
@jidrone and I are co-maintainers for now.
I included the patches from #217 and #223 as separate commits to the sandbox, thanks for those!
Then I did the subtree split for only modules/gcontent_field, and pushed that to the new project's repo.
Immediate TODO:
- Needs the few changes outside the modules/gcontent_field directory to either move into here or become a patch against Group core if needed.
- Needs to be renamed to the new "entitygroupfield" namespace.
- Open follow-up for migration path for sites currently running gcontent_field via patch.
Next phase:
- Go through remaining tasks and #210 and split off child issues in the new queue, then update the summary to cross off that item with a
[#x]link to the new issue.Thanks, everyone!
-Derek
Comment #243
dwwImmediate followup tasks are now here:
Comment #244
dwwOpened a ton of child issues for everything else in the summary except #210.
Saving work in progress so I don't lose anything. ;)
Comment #245
dwwOpened child issues for everything else. Summary is now complete and accurate.
Entity Group Field needs a lot of help before we're going to cut any official releases, but to save us all from the pain of a #250 comment monster issue, I'm going to call this one fixed.
Please join me in the child issues if you want to see a 1.0.0 release. ;)
Thanks!
-Derek
Comment #246
plousia commentedJust want to say, thanks everyone for their hard work on this - this is such a great functionality and makes the module so much more useful. Three cheers!