In search_api_page_admin_add() we have this code:

  $view_modes = array(
    'search_api_page_result' => t('Themed as search results'),
  );
  // For entities, we also add all entity view modes.
  if ($entity_info = entity_get_info($index->item_type)) {
    foreach ($entity_info['view modes'] as $mode => $mode_info) {
      $view_modes[$mode] = $mode_info['label'];
    }
  }
  if (count($view_modes) > 1) {
    $form['view_mode'] = array(
      '#type' => 'select',
      '#title' => t('View mode'),
      '#options' => $view_modes,
      '#description' => t('Select how search results will be displayed.'),
      '#size' => 1,
      '#default_value' => 'search_api_page_result',
    );
  }
  else {
    $form['view_mode'] = array(
      '#type' => 'value',
      '#value' => reset($view_modes),
    );
  }

If we are creating a search page with non-entities, the reset($view_modes) returns the item value ("Themed as search results"), not the key. Patch attached :)

CommentFileSizeAuthor
#1 1411852.patch685 bytesamateescu
results_view_mode.patch412 bytesamateescu

Comments

amateescu’s picture

StatusFileSize
new685 bytes

Same error in search_api_page_admin_edit().

bblake’s picture

Status: Needs review » Reviewed & tested by the community

Ran into the same problem. Verified the patch fixes it.

drunken monkey’s picture

Status: Reviewed & tested by the community » Fixed

Committed, thanks a lot for spotting and fixing!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.