Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
At the table built with the selected items, the description of each item is being built using the attribute #field_suffix, it can cause issues in some templates that are expecting the description at the most correct attribute that is #title. One example is Bootstrap Theme.
Proposed resolution
My suggestion is to change the attribute #field_suffix to #title at the $settings['column'] array.
Comment | File | Size | Author |
---|---|---|---|
#21 | 2524296-Fixing-title.patch | 657 bytes | arne_hortell |
#13 | checkbox_titles_missing-2524296-13.patch | 934 bytes | sudishth |
#2 | entityreference_view_widget_suffix-2524296-2.patch | 1.89 KB | m.stenta |
#2 | Screenshot from 2015-08-07 11:46:34.png | 9.04 KB | m.stenta |
fix-title.patch | 934 bytes | yseki |
Comments
Comment #1
DotmanBlue CreditAttribution: DotmanBlue commentedThanks for the patch. This fixed the title missing issue I was having in Bootstrap.
Comment #2
m.stentaI was experiencing the same issue with Bootstrap-based theme: labels were missing entirely (see attached screenshot). This is because a) Entityreference View Widget is adding the as markup to the #field_suffix, and b) Bootstrap does a bunch of HTML alterations to make the markup better suited for the Bootstrap CSS + JS.
As far as I can tell, the only reason that the label is being added to #field_suffix is to handle the "Display the rendered entity" use-case, where the entire entity is rendered as the label, instead of just the entity title.
That means, however, that the patch above will break the "Display the rendered entity" option. Because you can't stick the whole entity into a form element title.
Attached is a new patch that conditionally adds EITHER a #title, or a #field_prefix, depending on whether or not "Display the rendered entity" is checked. So this should handle both cases gracefully.
Comment #3
muschpusch CreditAttribution: muschpusch commentedEven though i'm not sure why the bootstrap theme isn't rendering the field_suffix the same problem occurs when rendering the whole entity on the field_suffix. A possible fix is to render the entity on the #title but that doesn't sound right.
Comment #4
lazzyvn CreditAttribution: lazzyvn commentedi have the same issue with bootstrap theme. it can't render "Display the rendered entity" when we define at field config view entityreference_view_widget can i do some modify with theme bootstrap?
I found themes/bootstrap/templates/system/form-element.func.php
bootstrap_form_element(&$variables)
this function don't add $build['element']['#suffix'] = $element['#field_suffix'];
so we can replace '#field_suffix' by '#suffix'
Comment #5
jeffdukedotcom CreditAttribution: jeffdukedotcom commentedany update on this?
Comment #6
lexa.mihu CreditAttribution: lexa.mihu commentedSame problem.
First patch worked for me. Patch #2 fixed the title problem but didn't save the values.
Comment #7
ConradFlashback CreditAttribution: ConradFlashback commentedfix-title.patch works for me.
Comment #8
drplfix-title.patch works for me also
Comment #9
B Boy Breaker CreditAttribution: B Boy Breaker commentedas #4 say changing to #suffix from #field_suffix is better than checking the entity like the patch #2
line 459 change #field_suffix to #suffix will fix this
Comment #10
emmanvazz CreditAttribution: emmanvazz as a volunteer commentedMy solution was similar to fix-title.patch.
Comment #11
pinueve CreditAttribution: pinueve commented+1 #9
just add some css
Comment #12
sudishth CreditAttribution: sudishth as a volunteer and at Azri Solutions commentedfix-title.patch
it is working for me
Comment #13
sudishth CreditAttribution: sudishth as a volunteer and at Azri Solutions commentedwell, attaching its reroll of fix-title.patch
Comment #14
sudishth CreditAttribution: sudishth as a volunteer and at Azri Solutions commentedComment #15
cravecode CreditAttribution: cravecode as a volunteer commentedI prefer the patch in comment #2. Works well for me. Thanks @m.stenta!
Comment #16
PhilYThanks to sudishth for patch #13 that is enough for me to bring back checkbox title (Drupal 7.56, Boostrap Theme 7.x-3.14 and Entity Reference View Widget 7.x-2.0-rc7)
Comment #17
jsacksick CreditAttribution: jsacksick commentedA new alter hook has been added (hook_entityreference_view_widget_rows_alter()), once implemented, you could loop over the rows and alter the #title and unset #field_suffix if necessary.
Comment #18
lelivero CreditAttribution: lelivero as a volunteer commentedIndeed! I've used the hook with this code to get the correct label:
Comment #19
m.stentaCan confirm that with the new version (2.1) and implementing @lelivero's hook in comment #18 above the issue is fixed for me! Thanks everyone!
Comment #20
candelas CreditAttribution: candelas as a volunteer commentedSolution in #18 works, thanks @lelivero
Comment #21
arne_hortell CreditAttribution: arne_hortell commentedAs i have understood it, field_suffix is for rendering things after the actual field.
Therefore, for me #13 doesnt make me happy and therefore i apply this patch which only adds the
title row from fix-title.patch but doesnt remove the field_suffix row.
Works fine for me.
Comment #22
Joran Lafleuriel CreditAttribution: Joran Lafleuriel commentedThanks @Liveiro ! ...for #18 wokrs fine in template.php