Author Topic: CiviCRM CCK Contact Reference auto-complete text field not working  (Read 3467 times)

hanschri

  • Guest
When typing a CCK Contact Reference name into the auto-complete text field cck field type, the auto complete function adds [cid:#] to the end of the name where # is the contact id of the user referenced, like: "Doe, John [cid:2]". When attempting to save node, drupal outputs this error: "[contact reference fieldname here]: found no valid post with that title.". If I erase the [cid:#] from the field and save I get no error, and the contact is referenced correctly.

If I edit the node after saving, I will once again have the [cid:#] appended to the name and I will not be able to save.

I'm running civiCRM in a separate database in multilingual mode (not sure if that matters). CCK version 6.x-2.2, 2.3 and latest dev has same issue. Is this a CiviCRM issue or a CCK issue?

Can some genius please tell me what to do? ;)
Thanks!

Offline locomo

  • I’m new here
  • *
  • Posts: 4
  • Karma: 2
Re: CiviCRM CCK Contact Reference auto-complete text field not working
« Reply #1 on: June 23, 2009, 01:38:36 pm »
i had the same problem

i'm just starting to understand how this module works and i'm not sure what the intention was behind doing it this way but i made a bandaid fix on my installation

i changed this line in the file "civicrm_cck.module"

from:
$matches["{$row['title']} [cid:{$id}]"] = '<div class="reference-autocomplete">'. $row['rendered'] . '</div>';

to:
$matches["{$row['title']}"] = '<div class="reference-autocomplete">'. $row['rendered'] . '</div>';

i also found that this field only auto-completes for contacts of type "Individual" but not "Organization" which is what i need to reference - this can be changed around line 628 in the same file

Offline kennedyusa058

  • I’m new here
  • *
  • Posts: 1
  • Karma: 0
Re: CiviCRM CCK Contact Reference auto-complete text field not working
« Reply #2 on: June 24, 2009, 07:15:12 pm »

Cheers and we look forward to your Forum Favourites selections!  :D

newbielink:http://pret-auto.org [nonactive]

hanschri

  • Guest
Re: CiviCRM CCK Contact Reference auto-complete text field not working
« Reply #3 on: June 26, 2009, 01:32:17 am »
Thanks, locomo, you genious you! Works like a charm. 

Offline mariagwyn

  • I post frequently
  • ***
  • Posts: 149
  • Karma: 4
  • CiviCRM version: CiviCRM 3.3.3
  • CMS version: Drupal 6.20
  • MySQL version: 5.2.14
  • PHP version: 5.0.91-50-log
Re: CiviCRM CCK Contact Reference auto-complete text field not working
« Reply #4 on: November 05, 2009, 03:46:06 pm »
locomo,

your fix works, as long as the node it not edited.  Once edited, the CID is replaced, and the error returns.  Is there someplace else in the module to modify?  I did a scan, but I am not seeing anything obvious.  But I am not a coder.

Offline siffring

  • I’m new here
  • *
  • Posts: 8
  • Karma: 0
Re: CiviCRM CCK Contact Reference auto-complete text field not working
« Reply #5 on: November 23, 2009, 12:49:08 pm »
Yeah, I'm seeing the same thing.

With this fix, when you create the node and do the auto complete, it pulls up Last Name, First Name (as it should).

When you go back and edit the node you'll see that the value of that field has been changed to Last Name, First Name [cid:123].

If you try to save this node without changing anything you'll get the error, "CiviCRM Contact: found no valid post with that title."

If you manually delete the [cid:123] from the field you can save without any errors.

So, the question is where is that [cid] getting set and how do we prevent it or hide it when editing the node?

I searched through the civi module, but can't seem to find where this is happening. Does anyone else have any ideas?

Offline Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 14736
  • Karma: 440
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: CiviCRM CCK Contact Reference auto-complete text field not working
« Reply #6 on: November 23, 2009, 03:32:38 pm »

you can take a look at (and potentially fix the code) here: drupal/modules/civicrm_cck/civicrm_cck.module


lobo
Found this reply helpful? Contribute NOW and help improve CiviCRM with the Make it Happen! initiative.