You are here

function entityreference_view_widget_preprocess_widget in Entity Reference View Widget 7

Implements hook_preprocess_HOOK().

File

./entityreference_view_widget.module, line 383

Code

function entityreference_view_widget_preprocess_widget(&$variables) {
  $form = $variables['form'];

  // Replace the placeholders in the view with actual checkboxes.
  $search = array();
  $replace = array();
  foreach ($form['#substitutions']['#value'] as $substitution) {
    $entity_id = $substitution['entity_id'];
    $search[] = $substitution['placeholder'];
    $replace[] = isset($form['add'][$entity_id]) ? drupal_render($form['add'][$entity_id]) : '';
  }
  $form['view']['#markup'] = str_replace($search, $replace, $form['view']['#markup']);
  $variables['selected_items'] = drupal_render($form['selected_items']);
  $variables['filters'] = drupal_render($form['filters']);
  $variables['pager_submit'] = drupal_render($form['pager_submit']);
  $variables['view'] = drupal_render($form['view']);
  unset($form['filters']);
  unset($form['selected_items']);
  unset($form['view']);
  unset($form['pager_submit']);
  $variables['extra'] = drupal_render_children($form);
}