Closed (fixed)
Project:
Automatic Entity Label
Version:
8.x-3.x-dev
Component:
Documentation
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
22 Nov 2016 at 09:18 UTC
Updated:
3 Jan 2023 at 14:04 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
peacog commentedComment #3
smith76 commentedHello,
The last patch auto_entity_label-2755445-20.patch works perfectly with "entity_browser" but I encounter the same error with the module "Profile": Symfony\Component\Routing\Exception\RouteNotFoundException: Route "entity.profile_type.auto_label" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName() (line 187 of core\lib\Drupal\Core\Routing\RouteProvider.php)
Thank you for your help
Comment #4
peacog commentedHi @Smith76, please try the latest patch #22 over on the main issue: #2755445: Auto Entity label does not set entity labels and breaks contrib modules. I think it will fix the error you're seeing.
Comment #5
smith76 commentedGreat ... it works fine :-)
Comment #6
smith76 commentedHi,
Sorry but new bug with the experimental module of core drupal "Content Moderation" :
Recoverable fatal error: Argument 1 passed to Drupal\auto_entitylabel\EntityDecorator::decorate() must be an instance of Drupal\Core\Entity\ContentEntityInterface, instance of Drupal\node\Entity\NodeType given, called in PATH\modules\auto_entitylabel\auto_entitylabel.module on line 52 and defined in Drupal\auto_entitylabel\EntityDecorator->decorate() (line 74 of modules\auto_entitylabel\src\EntityDecorator.php).
Comment #7
peacog commentedThanks @Smith76, I'll take a look. Would you mind posting your comments over on the other issue please #2755445: Auto Entity label does not set entity labels and breaks contrib modules? This issue is for a piece of functionality that hasn't been written yet. Thanks.
Comment #8
brunodboI'm looking to use auto_entitylabel with ECK (https://www.drupal.org/project/eck) in D8.
- Would integration between auto_entitylabel and ECK happen through the hook proposed in this issue?
- Is it possible to briefly describe what such a hook in auto_entitylabel would look like (what it should do, how it should work)? Looking for some pointers to help out with this. Thanks!
Comment #9
brunodboComment #10
darrick commentedI don't think a hook is required. I had success setting the ['links']['auto-label'] in the ConfigEntityType annotation.
Automatic Entity Label sets the above via hook_entity_type_alter() by ....
$entity_type->setLinkTemplate('auto-label', $entity_type->getLinkTemplate('edit-form') . "/auto-label");Comment #11
hypertext200Closing #2722921: Automatic Entity Label not working with ECK entities as duplicate.
Comment #12
hypertext200Following code does not work for Custom ECK entities. Any other suggestions?
$entity_type->setLinkTemplate('auto-label', $entity_type->getLinkTemplate('edit-form') . "/auto-label");Comment #13
daggerhart commentedTook me a little bit of playing around, but I finally got this working generically with ECK.
Here is an example hook that will enable the auto-label form for all ECK bundles:
Note: that the "Automatic Label" link does not appear as a tab when editing a bundle, but it is available in the dropdown menu for a bundle when viewing the bundle list of an ECK entity type.
Additionally I wanted easy access to the tokens available to the entity, so here is an example hook of adding the relevant tokens to the token browser:
Ideally, these things are included in this module in some (likely-better) way.
Comment #14
robpowell@daggerhart Thanks so much for posting example. This allowed me to extend this module for group. I am working off of dev and wanted to add that the tabs and tokens did show up.
Comment #15
brooke_heaton commentedWould it be desirable to add the form_alter functionality to this module for Groups? The custom solution isn't very accessible to many site builders?
Comment #16
brooke_heaton commentedComment #17
kclarkson commented@brooke_heaton,
I just ran into this issue today.
It would be super awesome for someone to provide a patch to allow site builders to use this with ECK :)
thanks again
Comment #18
bgilhome commentedAnother way to add tokens for your own custom entity type MYTYPE (defined in MYMODULE):
(Presuming your entity type edit route is defined with a path including a '/{MYTYPE}/' parameter).
Comment #19
anybodyThank you very much. I think this should be documented in an .api.php file for other developers shouldn't it?
That should list up the several ways mentioned here to add support to custom entity types.
Thank you all very much so far!
Comment #20
daggerhart commentedHere's a first-pass at adding these examples to an .api.php file within the module.
Comment #21
Anonymous (not verified) commentedTried the approach in #13 with eck and the provided patch installed.
However, this doesn't seem to actually work. While it adds the auto entity label form to ECK, it doesn't actually perform any of the actions on the eck entity when saved.
For example is I select "Automatically generate the label and hide the label field" and go edit the eck entity, the title field is still there. It also doesn't auto generate the label.
Comment #22
daggerhart commentedHmmm... I was 99% sure this worked, so I dug into the code a bit and found a discrepancy in how the config data is stored for entity bundles that leverage this module.
On saving the settings form, it saves the values to a config object using the entity type provider id as a key. But in the entity decorator, it is looking for the settings using the entity type as a key.
This issue has a working patch that addresses the problem #2923876: Broken when provider !=entityTypeId. With that patch applied this example code works for me. The only problem with the patch as I see it is that it doesn't provide an update hook that automatically fixes the stored config keys. I will comment on that issue with the suggestion.
Comment #23
brooke_heaton commentedHuh, bummer. #13 is working for me on my Group type per #16.
Comment #24
scottrigbyAgree with #22 this works well with #2923876: Broken when provider !=entityTypeId
Comment #25
caldenjacobs commentedRe-roll of #20 for latest dev release.
As with #22, works with #2923876: Broken when provider !=entityTypeId
Comment #26
kris77 commented@caldenjacob,
Do I have to replace "MYMODULE" with "auto_entitylabel"?
Thanks.
Comment #27
zanvidmar commentedFist thank you for all work and patches made for this module.
I took me some time to gather all data from this post and from https://www.drupal.org/project/auto_entitylabel/issues/2923876 to make it work.
I am posting this for anyone that want to enable automatic label for their custom entities.
1. use development version
composer require 'drupal/auto_entitylabel:2.x-dev'2. Apply two patches:
- https://www.drupal.org/files/issues/2018-09-22/2829571-provide-a-hook-fo...
- https://www.drupal.org/files/issues/2019-01-19/auto_entitylabel-2923876-...
3. Create custom hook
Where "HOOK" is "your_module_name" (@Kris77)
and "your_module" must be replaced with module that provides your custom entity
Based on my testing with approach described above, both patches on dev branch works perfectly.
Comment #28
skdrupal88Thanks for patches, and thanks @zanvidmar, your instruction works great.
Comment #29
willabby commented@zanvidmar thanks for your instructions. I am trying to get this to work with Group module (8.x-1.0-rc2) and Auto Entity Label dev version. Following your instructions, Auto Entity Label works on the Group Type, but does not work on the Group Content Type (i replaced 'group' with 'group_content' for entity type. It only adds the "Auto Label" tab with a path to /auto-label, which results in error message. Do you have otherwise?
Auto Entity Label is also not working on any of my content types, I get the following error message saving a node with AEL:
`Cannot load GroupContent entities for an unsaved entity`
I would be interested to know if you have getting any similar errors with Group Module. Thank you.
Comment #30
zanvidmar commented@willabby where did you replaced "'group' with 'group_content'" ? Can you share the code?
I did not tried this with Group module (yet).
Comment #31
willabby commented@zanvidmar this is the code I put in a custom module, I wasn't sure if where you had 'your_module' if I should put the module providing the entity type (gnode)? or the actual entity type (group_content), but I tried both, and both resulted in same error. (As I mentioned though, the first `foreach` for `group` works on the group entity per your instructions)
Also, if I click on the automatic label tab for the group content configuration (I was not sure if I set autolabel on the content type, if I needed to do anything with the group content entity too?), i get this error:
Error: Call to a member function id() on null in Drupal\auto_entitylabel\Form\AutoEntityLabelForm->__construct() (line 103 of modules/contrib/auto_entitylabel/src/Form/AutoEntityLabelForm.php).
Thank for any help you can provide!
UPDATE: My issue seemed to be caused by this patch (https://www.drupal.org/project/group/issues/2774827) providing tokens for group module, when I updated patch to latest version, error went away, and I am able to use auto entity label on nodes now.
Comment #32
colanComment #33
mortona2k commentedI'm not sure how to make this work for custom entities. I have:
But that route is showing page not found.
Why would it be $entity_type->getLinkTemplate('edit-form') . "/auto-label"? It seems like this would be the url for editing each entity, not the overall entity settings?
BTW the patch in https://www.drupal.org/project/auto_entitylabel/issues/2923876 is applied to 2.x and 3.x so not needed anymore.
Comment #34
mortona2k commentedI have a bundleless entity, so patch #11 from here is needed too: https://www.drupal.org/project/auto_entitylabel/issues/2829571#comment-1...
Comment #35
liquidcms commentedWondering if there is a solution today for supporting AEL on contrib entities?
I have a bundless entity called "sitewide alert" (https://www.drupal.org/project/sitewide_alert) with core 9.1 and latest AEL and:
- patch from here
- this code:
and when i go to the entity config page for the entity type: admin/config/sitewide_alerts and add on auto-label, i get 404.
I see there is a very old patch for bundleless which does not apply to current release. Is a refactored version of that patch the missing piece here?
Comment #36
dqdWould love to see somebody chiming in here for a reroll considering all the latest comments. I will review asap and commit if RTBC.
Comment #37
pasqualleThe patch still applies, and it only adds information to the API documentation. I have nothing to improve for this patch.
Comment #39
vladimiraus