I'm trying to create an edit view that will show a thumbnail of an image with the editable title next to it. I've got a list that works fine in table view, however changing it to an editview I lose the images.

Any ideas?

Comments

dman’s picture

I've replaced
editview_field_form_render() [296]
with:

/**
 * Implementation of hook_field_form_render()
 */
function editview_field_form_render($field, &$form, $view) {
  $element = array('class' => 'editview-field editview-'. preg_replace('/[^a-z0-9]+/', '-', strtolower($field['fullname'])));
  $element['valign'] = 'top';

  $vocab_id = str_replace('term_node_', '', $field['tablename']);
  if (is_numeric($vocab_id)) {
    if( $form['taxonomy'][$vocab_id]) {
      unset($form['taxonomy'][$vocab_id]['#description']);
      $element['data'] = drupal_render($form['taxonomy'][$vocab_id]);
    }
    else {
      unset($form['taxonomy']['tags'][$vocab_id]['#description']);
      $element['data'] = drupal_render($form['taxonomy']['tags'][$vocab_id]);
    }
  }
  else {
    if($field['handler'] == 'image_views_handler_image_img') {
      $element['data'] .= l($form['thumbnail']['#value'], 'node/'.$form['#node']->nid, array(), NULL, NULL, NULL, TRUE);
      return $element;
    }

    switch ($field['field']) {
      case 'iid':
        unset($form['image_attach']['iid']['#description']);
        $element['data'] = drupal_render($form['image_attach']['iid']);
        $form['image_attach']['image']['#size'] = 20;
        $element['data'] .= drupal_render($form['image_attach']['image']);
        break;
      case 'field_product_links_url':
        unset($form['field_product_links']['more']);
        unset($form['field_product_links']['tokens']);
        $element['data'] = drupal_render($form['field_product_links']);
        break;
      default:
        $element['data'] = editview_search_for_field($field, $form, $view);
        break;
    }
  }
  return empty($element['data']) ? null : $element;
}

... this supports images, and also has a patch for taxonomies. Only freetagging was showing up before IIRC - this now allows both.
Compare with yours and merge carefully.
It's the

    if($field['handler'] == 'image_views_handler_image_img') {
      $element['data'] .= l($form['thumbnail']['#value'], 'node/'.$form['#node']->nid, array(), NULL, NULL, NULL, TRUE);
      return $element;
    }

you need

Jorge-2’s picture

Version: 5.x-0.3 » 6.x-1.0-beta1

Hello dman,
I'm wondering if you have changed editview module (or have any idea about how to do) with the same characteristic to the new version of Drupal (6), Editview (6.x-1.0-beta1) and Taxonomy images. I was looking in the files, but the code has changed and my php skills are very poor.

I'm looking for change Taxonomy terms and show Images, Taxonomy terms and images and, if posible, Labels (Nid for example) and Links with Editview.

Many thansks in advance for any help.

Jorge

paul2’s picture

Here is an update that works for 6.x-1.0-beta1 (I just figured it out, not that I have a clue how Views works from a PHP point of view, but I figured this much out!).

Edit theme/editview.theme.inc. In function editview_field_form_render(), replace this line:

$element['data'] = _editview_form_field($form, $field->field);

with this chunk of code:

          // If the field is an image field, show thumbnail.
          if($field->field == 'image_image') {
            $element['data'] = $form['image']['thumbnail']['#value'];
          } else {
            $element['data'] = _editview_form_field($form, $field->field);
          }

Seems to do the trick.