You are here

function properties_autocomplete_js in Dynamic properties 7

Page callback for autocomplete suggestions.

1 string reference to 'properties_autocomplete_js'
properties_menu in ./properties.module
Implements hook_menu().

File

./properties.module, line 153
This module provides a dynamic property field that can contain an unlimited number of attribute value pairs.

Code

function properties_autocomplete_js($type, $string = NULL) {
  $function = 'properties_' . $type . '_load_paging';
  if (!function_exists($function)) {
    return;
  }
  $suggestions = $function(10, array(
    'search' => $string,
  ));
  $json_suggestions = array();
  foreach ($suggestions as $suggestion) {
    $json_suggestions[$suggestion->name] = t('@name (@label)', array(
      '@name' => $suggestion->name,
      '@label' => $suggestion->label,
    ));
  }
  drupal_json_output((object) $json_suggestions);
}