Hey guys,

I wanted to create a Entity Reference field with a Entity Reference view as source for the list. The view is simply showing the email addresses of all administrative users.
In the field definition (see "default value") the dropdown shows the email addresses as desired. When I save the field settings and go to a node edit page the dropdown shows the correct users, but not their email addresses but only the user names.

This looks like a bug to me. I could not find a similar problem in the issue list.

Cheers,
Johannes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

amfranco’s picture

Hi, I have the same problem. Did you solve this?

Sarenc’s picture

Issue summary: View changes

I have this issue too.

Sarenc’s picture

I used a form_alter to deal with this.

// convert idirs to emails in field_trusted_assistants
  if (isset($form['field_trusted_assistants'][$form['field_trusted_assistants']['#language']]['#default_value']) &&
      $form['field_trusted_assistants'][$form['field_trusted_assistants']['#language']]['#default_value']) {
    $idirs = explode(',', $form['field_trusted_assistants'][$form['field_trusted_assistants']['#language']]['#default_value']);
    foreach ($idirs as &$idir) {
      preg_match('/\((.*?)\)/', $idir, $match);
      if (isset($match[1]) && is_numeric($match[1])) {
        $delegate = user_load($match[1]);
        if ($delegate) {
          $idir = $delegate->mail . ' (' . $delegate->uid . ')';
        }
      }
    }
    $form['field_trusted_assistants'][$form['field_trusted_assistants']['#language']]['#default_value'] = implode(', ', $idirs);
  }