Index: popups_reference.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/popups_reference/popups_reference.module,v retrieving revision 1.4.2.2 diff -u -p -r1.4.2.2 popups_reference.module --- popups_reference.module 21 Mar 2009 01:03:20 -0000 1.4.2.2 +++ popups_reference.module 26 Mar 2009 22:16:28 -0000 @@ -86,14 +86,21 @@ function popups_reference_alter_item(&$f variable_get('popups_reference_show_add_link_'. $field_name, TRUE)) { $type = $form['type']['#value']; $field = content_fields($field_name, $type); - - $wrapper_id = 'popups-reference-' . _popups_reference_counter(); - $links = _popups_reference_links($field, $type, $wrapper_id, $field['widget']['type']); - if ($links) { - // Put the nodereference widget and links in an wrapper. - // Makes it easy to find for Ahah targeting, and popups_reference behavior selecting. - $form[$key]['#prefix'] = '
'; - $form[$key]['#suffix'] = '
Add New: ' . implode(', ', $links) .'
'; + + // we may have multiple fields in case of 'unlimited' + foreach ($form[$field_name] as $key => $value) { + if (is_numeric($key)) { + // add link + $wrapper_id = 'popups-reference-' . _popups_reference_counter(); + $links = _popups_reference_links($field, $type, $wrapper_id, $field['widget']['type']); + if ($links) { + // Put the nodereference widget and links in an wrapper. + // Makes it easy to find for Ahah targeting, and popups_reference behavior selecting. + $form[$field_name][$key]['#prefix'] .= '
'; + $form[$field_name][$key]['#suffix'] = '
Add New: ' . implode(', ', $links) .'
'. (!empty($form[$field_name][$key]['#suffix']) ? $form[$field_name][$key]['#suffix'] : ''); + + } + } } } }