After saving a node with entity reference views, I'm getting this error:
Notice: Undefined index: field in entityreference_view_widget_validate() (line 467 of /home/username/public_html/sites/all/modules/entityreference_view_widget/entityreference_view_widget.module).

Comments

alieffring’s picture

I'm encountering the same error, and digging into it, it looks like the problem is that the data it's trying to assign to $target_type from
$form_state['field'][$field_name][$language]['field']['settings']['target_type']
is actually in
$form_state['field']['#parents'][$profile_type]['#fields'][$field_name][$language]['field']['settings']['target_type']

where $profile_type is the machine name of the Profile2 profile I'm using the Entity Reference View Widget in. Is the problem perhaps that $form_state is structured differently for profiles?

edit:

$element has a parameter named #parents which is an array, containing a single entry which is the name of my profile type. I don't know where this #parents array is coming from, so I can't figure out what things look like when there's more than one entry, but I have a hunch that it can be used with code that at least roughly resembles this:

  $field_base = $form_state['field'];
  if(!empty($element['#field_parents'])) {
    $field_base = $field_base['#parents'];
    foreach($element['#field_parents'] as $parent) {
      $field_base = $field_base[$parent];
    }
    $field_base = $field_base['#fields'];
  }
  $target_type = $field_base[$field_name][$language]['field']['settings']['target_type'];
tseven’s picture

I've posted a patch which fixes this issue on the current dev version of the module at:
http://drupal.org/node/1820278#comment-6636080

stella’s picture

Status: Active » Closed (duplicate)