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.

Comments

dotmanblue’s picture

Thanks for the patch. This fixed the title missing issue I was having in Bootstrap.

m.stenta’s picture

Title: Problem with suffix and title » Checkbox titles missing with Bootstrap theme
Status: Active » Needs review
Issue tags: -suffix, -title
StatusFileSize
new9.04 KB
new1.89 KB

I 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.

muschpusch’s picture

Status: Needs review » Needs work

Even 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.

lazzyvn’s picture

i 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'

jeffdukedotcom’s picture

any update on this?

lexa.mihu’s picture

Same problem.
First patch worked for me. Patch #2 fixed the title problem but didn't save the values.

ConradFlashback’s picture

fix-title.patch works for me.

drpl’s picture

fix-title.patch works for me also

B Boy Breaker’s picture

as #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

emmanvazz’s picture

My solution was similar to fix-title.patch.

pinueve’s picture

+1 #9

just add some css

#YOURTABLEID tr td .form-item {
  position: relative; 
  float: left;
  padding-right:10px;
}
sudishth’s picture

fix-title.patch
it is working for me

sudishth’s picture

StatusFileSize
new934 bytes

well, attaching its reroll of fix-title.patch

sudishth’s picture

Status: Needs work » Needs review
cravecode’s picture

I prefer the patch in comment #2. Works well for me. Thanks @m.stenta!

phily’s picture

Thanks 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)

jsacksick’s picture

Status: Needs review » Closed (won't fix)

A 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.

lelivero’s picture

Indeed! I've used the hook with this code to get the correct label:

function YOURMODULE_entityreference_view_widget_rows_alter(&$rows, $entities, $settings) {
  foreach (element_children($rows) as $key => $child) {
    if ($rows[$key]['target_id']['#type'] == 'checkbox') {
      $rows[$key]['target_id']['#title'] = $rows[$key]['target_id']['#field_suffix'];
    }
  }  
}
m.stenta’s picture

Can 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!

candelas’s picture

Solution in #18 works, thanks @lelivero

arne_hortell’s picture

StatusFileSize
new657 bytes

As 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.

joran lafleuriel’s picture

Thanks @Liveiro ! ...for #18 wokrs fine in template.php