Needs work
Project:
Automatic Entity Label
Version:
8.x-3.x-dev
Component:
Code
Priority:
Minor
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
3 Jul 2019 at 15:24 UTC
Updated:
14 May 2026 at 12:47 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
QuietSpecialist commentedComment #3
colanIs this still a problem in the latest dev branch?
Comment #4
QuietSpecialist commentedHi,
I'll take a look this weekend.
Comment #5
joele75 commentedCan confirm the title field still displays using latest dev branch when adding/editing an inline custom block type in Layout Builder.
Drupal version 8.76
Comment #6
chris burge commentedYes, this is still an issue with Drupal Core 8.7.6 and Auto Entity Label 8.x-3.0-dev. When adding an inline block, the Title field is unaffected by Auto Entity Label.
Extending to Auto Entity Label to support Layout Builder should be pretty straightforward. Take a look at https://www.drupal.org/project/inline_block_title_automatic.
Comment #7
chris burge commentedComment #8
chris burge commentedEvery block has a 'Block description', which can be thought of as an admin title. This is the value that Automatic Entity Label currently modifies. (The block description is not editable from Layout Builder.)
When we work in Layout Builder, every element is placed as a component. Each component has its own attributes, which include a component title. In the case where a block is placed in Layout Builder, the component title belongs to the component, not to the block. The component title is the subject of this issue.
The issue requests to extend Automatic Entity Label to modify component labels belonging to blocks placed in Layout Builder in addition to overriding their block descriptions.
Comment #9
chris burge commentedWe've decided to go another direction with our project; however, I'm attaching a patch of my work thus far in case someone else wants to take this up.
The attached patch implements the UI (hiding/showing the component title on Layout Builder forms). It doesn't store the auto label for the Layout Builder component. That part still needs written.
Comment #10
colanUpdating status. Thanks for this!
Comment #11
aarnau commentedHello, applying the patch I have obtained the following notice: Undefined variable: layout_builder_form in auto_entitylabel_prepare_entityform() (line 204 of modules/contrib/auto_entitylabel/auto_entitylabel.module)
I have rebuilt the patch so it doesn't report the notice.
Comment #12
colan#11: Please provide interdiffs when posting patches.
Comment #13
nwom commentedThis would be amazing to have, since it would replace the need for Inline Block Title Automatic and allow you to automatically create a description like "PARENT NODE TITLE - BLOCK TYPE" which would be alot more descriptive than what is currently possible in the aforementioned module. The other advantage is that displaying the title would be configurable, whereas the other module always hides the label.
Comment #14
andyg5000As a heads up, it looks like this patch is causing the notice described in #3214673: Undefined index: #form_id in auto_entitylabel_prepare_entityform() (line 166 of modules/contrib/auto_entitylabel/auto_entitylabel.module).
Comment #15
andyg5000Here's the requested interdiff from #9-#11
Comment #16
andyg5000Here's a fix to #14 rolling with the changes in #11.
Comment #17
gromani14 commentedPatch is not working... just re-rolled the same patch. (looks like a commit 6 month ago added a line on the uses section)
Comment #18
galactus86 commentedHello.
I just applied the patch from #17 and it seems to be working fine.
I am on Drupal core 9.5.3
Comment #19
codechefmarcStrange - I'm trying the patch in #17 and anything I put into the "Pattern for the label" field gets replaced with ""%AutoEntityLabel%" block" and not the text I specified. I tried using both regular text and a token replacement.
Comment #20
megan_m commentedThe ""%AutoEntityLabel%" block" text is appearing for me only in Layout builder. It's not displayed on the front-end.
Comment #21
simon georges commentedIn my case, the patch in #17 was allowing the prepare_form to execute for Inline Blocks, but the form was not actually correctly prepared. Fix the attached fix, it works for me... Let's hope it's the case for all of you as well ;-)
Comment #22
codechefmarcI just tried your patch, Simon, and it worked for me but only in the
/admin/content/blockarea. It didn't work for me for when you're adding blocks inline inside layout builder itself.I tried #17 as well and it only sort of works for me - the default value for the admin label isn't getting set appropriately. I'm using the "Automatically generate the label if the label field is left empty". It will set the value correctly in the DB, but not in the admin label field, so (for example we have an Accordion block) it will put the block name in the field instead of what we put as the auto label, so it will put "Accordion". I think I found a fix for this, but, the preview text doesn't work yet, so I'm still working through that piece.
Comment #23
socialnicheguru commentedComment #24
simon georges commented@codechefmarc, the patch works for me in the Layout Builder as well, so I'm wondering what contrib module I have that could alter this... I'll check back at work this week, thanks for your feedback!
Comment #25
xavier.massonI agree with @codechefmarc patch #21 doesn't work for me but #17 does within the layout builder.
The block form is generated from
core/lib/Drupal/Core/Block/BlockPluginTrait.phpline 173 :the interdiff between 17-21 merge oldly the
$widget['value']directly within the label (textfield form element) but after the #20 patch it was applied to nested elements as$form['settings']['label']['value].Comment #26
codechefmarcI've started some work in an MR - it's not ready yet as it still has some problems, but I based it off of #17 and started adding some things of my own. Mainly, once someone adds a block with auto_entitylabel, it was saving the correct auto label in the database, but not setting that as the block administrative title. So, I added some code to the
auto_entitylabel_prepare_entityformfunction that still gets a decorated entity but splits that into its own variable. Then, we can use the passed in$entityto get a default value (I'm specifically testing for thecase AutoEntityLabelManager::OPTIONAL:.This works ... sort of. You have to save the block twice for it to actually take in the UI when not previewing the content and instead layout builder only shows the administrative titles. See new screenshots:
So, what I think needs to be done is to play with the
auto_entitylabel_entity_prepare_viewand/orauto_entitylabel_entity_presavefunctions to make sure it's saving the admin title so layout builder can read it correctly? I'm not as well versed with the entity API, so I'm running a little bit out of my comfort zone but I'll still press on to see what else I can do.As a second issue here, if I choose to hide the label field and auto generate, I get the
%AutoEntityLabel%as previously reported. That's, I think, being provided on line 185 (in my MR below) so that's something separate to troubleshoot.See here for my current changes (Note again, this is not ready for merging yet):
https://git.drupalcode.org/issue/auto_entitylabel-3065687/-/compare/8.x-...
Comment #27
xavier.massonIn case we are in the Layout builder form does the label value must be directly generated for the
AutoEntityLabelManager::ENABLEDto avoid to have%AutoEntityLabel%displayed until to save the layout builder and invokeauto_entitylabel_entity_presave?Like below :
@codechefmarc i'll try to give a try to your work in progress to give some feedbacks.
Comment #28
anybodyComment #29
socialnicheguru commentedReroll of patch #17 for auto_entitylabel 3.3.0
Comment #30
anybodyRelabeled as a bug in combination with layout builder. As a workaround you can maybe just remove the title block in layout builder?
Comment #31
hctomI just checked the patch from #29 with Drupal 10.3.2 and unfortunately it is for me also only working when creating a block content via Admin -> Content -> Blocks -> Add content block.
When using it with the "Automatically generate the label and hide the label field" setting in layout builder context with an inline block, the field is hidden as expected, but the label is always
%AutoEntityLabel%(even when updating the inline block later).I think the biggest problem here, is that for new/updated inline blocks, the
auto_entitylabel_entity_presave()hook is not called directly when adding/updating the block, but when the surrounding entity's layout is saved as a whole. I debugged through the code and saw thatAutoEntityLabelManager::setLabel()actually gets the correct label, but setting it on the inline block entity does not work somehow.But in order to have the correct label immediately after adding/updating an inline block in layout builder context, maybe the label field value has to be set during validation or similar, so it is always available, even when the surrounding layout has not been saved as a whole?
Comment #32
micnap commentedCorrecting an issue that was showing up when trying to add a chart from the Charts module (https://www.drupal.org/project/charts). We're getting the following error with this patch when trying to add a Charts block to layout builder if the Charts block isn't figured correctly:
"Warning: Undefined array key 1 in auto_entitylabel_form_layout_builder_add_block_alter() (line 112 of modules/contrib/auto_entitylabel/auto_entitylabel.module)."
It's complaining about block_bundle in
list($plugin_id, $block_bundle) = explode(':', $build_info['args'][3]);As $block_bundle isn't being used anywhere, removed it from the patch.
Comment #33
luukyb commentedI had the same issue as @micnap, removing $block_bundle worked for me too.