Hello
i use entity reference view widget it return only checkbox not all informations defined in config. It works fine with another theme. i dont know why it doesnt work with bootstrap theme.
function bootstrap_form_element return $build without teste if existe field_prefix or field_suffix

suggestion

// Build the form element.
    $build['element'] = array(
      '#markup' => $element['#children'],
      '#prefix' => !empty($prefix) ? $prefix : NULL,
      '#suffix' => !empty($suffix) ? $suffix : NULL,
    );
  }else{
    if(!empty($element['#field_suffix'])) {
      $build['element']['#suffix'] = $element['#field_suffix'];
    }
    if(!empty($element['#field_prefix'])) {
      $build['element']['#prefix'] = $element['#field_prefix'];
    }
  }
CommentFileSizeAuthor
#6 Screenshot from 2016-01-27 12-20-31.png11.06 KBgge
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

lazzyvn created an issue. See original summary.

lazzyvn’s picture

Issue summary: View changes
markhalliwell’s picture

Version: 7.x-4.x-dev » 7.x-3.x-dev
Component: Templates » Miscellaneous
Assigned: lazzyvn » Unassigned
Category: Bug report » Support request
Priority: Major » Normal
Status: Active » Closed (won't fix)
Issue tags: -entity reference view widget bootstrap

This issue queue isn't for support or debugging integration with other modules. Not all modules are supported out-of-the-box. Most of the time, the issue is with the module itself rather than the theme (despite it working in other, "core", themes) due to how they implement core APIs (or lack thereof).

lazzyvn’s picture

because bootstrap theme dont support #field_suffix
i have to modify theme boostrap
/themes/bootstrap/templates/system/form-element.func.php
function bootstrap_form_element(&$variables)
and note when you update version


// Build the form element.
    $build['element'] = array(
      '#markup' => $element['#children'],
      '#prefix' => !empty($prefix) ? $prefix : NULL,
      '#suffix' => !empty($suffix) ? $suffix : NULL,
    );
  }

else{
    if(!empty($element['#field_suffix'])) {
      $build['element']['#suffix'] = $element['#field_suffix'];
    }
    if(!empty($element['#field_prefix'])) {
      $build['element']['#prefix'] = $element['#field_prefix'];
    }
  }
lazzyvn’s picture

Issue summary: View changes
Priority: Normal » Major
Status: Closed (won't fix) » Needs review

i dont understand why bootstrap function bootstrap_form_element does not support #field_suffix ? it is very helpful for another hook

gge’s picture

I modified form-element.func.php as @lazzyvn mentioned but I think this needs a bit more attention...

Expected html output:

<div class="form-item ...">
  <label class="control-label" for="..."><input type="checkbox" id="..." name="..." value="..." class="form-checkbox">Test</label>
</div>

The actual html output:

<div class="form-item ...">
  <label class="option" for="..."><input type="checkbox" id="..." name="..." value="..." class="form-checkbox">Test</label>
  <label class="control-label" for="..."><input type="checkbox" id="..." name="..." value="..." class="form-checkbox"></label>
</div>

Screenshot

lazzyvn’s picture

it will create 2 input checkbox? when you want output only label (title)? don't have it I use Display the rendered entity and i set view mode with field i want show it. I will check it again

gge’s picture

Sorry, it seems that 2 labels are created on node add/edit form and 1 checkbox.
To simplify it, instead of

<div>
  <label><input>Test</label>
</div>

I get this

<div>
  <label>Test</label>
  <label><input></label>
</div>
markhalliwell’s picture

Priority: Major » Normal
Status: Needs review » Closed (works as designed)
thlo7777’s picture

I tried add field_suffix and field_prefix in bootstrap/templates/system/form-element-label.func.php. That is ok for me. Please help me to review it if it's correct. Thanks a lot :) Bootstrap theme version 7.x-3.5

// Inject the rendered checkbox or radio element inside the label.
    if (!empty($element['#children'])) {

      //Thlo added for checkbox and radio bootstrap theme. The question is how impact other checkbox and radios
      $prefix = isset($element['#field_prefix']) ? $element['#field_prefix'] : '';
      $suffix = isset($element['#field_suffix']) ? $element['#field_suffix'] : '';

      if (!empty($prefix)) {
          $prefix = '<span class="field-prefix' . $prefix . '</span>';
      }

      if (!empty($suffix)) {
          $suffix = '<span class="field-suffix' . $suffix . '</span>';
      }

      $output .= $prefix . $element['#children'] . $suffix;
    }
vlooivlerke’s picture

@thlo7777 Your solution did not work for me, It created duplicate form fields if you use a placeholder.

this worked for me
I modified form-element.func.php

    // Build the form element.
    $build['element'] = array(
      '#markup' => $element['#children'],
      '#prefix' => !empty($prefix) ? $prefix : NULL,
      '#suffix' => !empty($suffix) ? $suffix : NULL,
      '#weight' => 1,
    );
  }

else{
    if(!empty($element['#field_suffix'])) {
      $build['element']['#suffix'] = $element['#field_suffix'];
    }
    if(!empty($element['#field_prefix'])) {
      $build['element']['#prefix'] = $element['#field_prefix'];
    }
  }
code38’s picture

same problem for me and the modification from @vlooivlerke in form-element.func.php solve the problem.
thanks a lot.

titouille’s picture

Like gge, the output is inverted:

<div>
  <label>Test</label>
  <label><input></label>
</div>

instead of

<div>
  <label><input>Test</label>
</div>

If you read the comment in bootstrap_form_element :

  // Checkboxes and radios render the input element inside the label. If the
  // element is neither of those, then the input element must be rendered here.

important think is "render the input element inside the label". So #field_prefix and/or #field_suffix must be added to label key, not element key:

    // Build the form element.
    $build['element'] = array(
      '#markup' => $element['#children'],
      '#prefix' => !empty($prefix) ? $prefix : NULL,
      '#suffix' => !empty($suffix) ? $suffix : NULL,
      '#weight' => 1,
    );
  }
  else{
    if(!empty($element['#field_suffix'])) {
      $build['label']['#suffix'] = $element['#field_suffix'];
    }
    if(!empty($element['#field_prefix'])) {
      $build['label']['#prefix'] = $element['#field_prefix'];
    }
  }

In order to have a correct display. For entityreference_view_widget, #field_suffix is not included in label directly, but at least the position is correct (after the checkbox).

aqmaster’s picture

Thank you so much. @titouille this worked for me. (Y)

thlo7777’s picture

Thank you @vlooivlerke and @titouille. Your solution save my time

pinueve’s picture