1

Auto complete search in civicrm does not show any result if the search field contains apostrophe.Any comment(s) would be highly appreciated.

DRUPWAY
  • 345
  • 6
  • 16
  • 1
    can you please put the code so we can help you ? – Youness Jul 28 '14 at 08:39
  • I have created a select list for a civicrm custom fields and the field is auto completed type. Auto complete functionality working fine all case instated of field item contains apostrophe. – DRUPWAY Aug 21 '14 at 14:50

2 Answers2

1

This is a issue in civicrm " drupal_site\sites\all\modules\civicrm\CRM\Contact\Page\AJAX.php"

 static function autocomplete() {
    $fieldID       = CRM_Utils_Type::escape($_GET['cfid'], 'Integer');
    $optionGroupID = CRM_Utils_Type::escape($_GET['ogid'], 'Integer');
    $label         = CRM_Utils_Type::escape($_GET['s'], 'String');

    $selectOption = CRM_Core_BAO_CustomOption::valuesByID($fieldID, $optionGroupID);

    $completeList = NULL;
    foreach ($selectOption as $id => $value) {
      if (strtolower($label) == strtolower(substr($value, 0, strlen($label)))) {
        echo $completeList = "$value|$id\n";
      }
    }
    CRM_Utils_System::civiExit();
  }

Need to remove escape function.

$label         = $_GET['s'];

Solved my issue.

DRUPWAY
  • 345
  • 6
  • 16
0

you should escape the string before you add it to the array using the addslashes(); function in php like this :

PHP :

$str="this a string with ' ";
$str=addslashes($str);

JS :

var string_from_php=<?php echo $str; ?>

and that should work just fin. if you added a snipet from your code that populate the array that gos to the autocomplet i wouldv been much more of a help

Youness
  • 1,468
  • 1
  • 9
  • 19