1

如果搜索字段包含撇号,则 civicrm 中的自动完成搜索不会显示任何结果。任何评论将不胜感激。

4

2 回答 2

1

这是 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();
  }

需要去掉转义功能。

$label         = $_GET['s'];

解决了我的问题。

于 2014-08-21T15:45:31.467 回答
0

addslashes();在使用php中的函数将其添加到数组之前,您应该转义字符串,如下所示:

PHP:

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

JS:

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

这应该可以正常工作。如果您从代码中添加了一个片段来填充进入自动完成的数组,我会更有帮助

于 2014-08-21T15:37:19.050 回答