function _autocomplete_widgets_get_options in Autocomplete Widgets for Text and Number Fields 7
Same name and namespace in other branches
- 6 autocomplete_widgets.common.inc \_autocomplete_widgets_get_options()
Fetch an array of options for the given widget.
Parameters
$instance: A structured array describing the field instance.
$string: Optional string to filter values on (used by autocomplete).
$match: Operator to match filtered name against. Can be any of: 'contains', 'equals', 'starts_with'
$keys: Optional keys to lookup (the $string and $match arguments will be ignored).
$limit: If non-zero, limit the size of the result set.
Return value
An array of valid values in the form: array( key => value, ... )
4 calls to _autocomplete_widgets_get_options()
- autocomplete_widgets_element_process in ./
autocomplete_widgets.module - Process an individual textfield autocomplete element.
- autocomplete_widgets_field_widget_form in ./
autocomplete_widgets.module - Implementation of hook_field_widget_form().
- autocomplete_widgets_json in ./
autocomplete_widgets.module - Menu callback; Retrieve the autocomplete suggestions.
- _autocomplete_widgets_validate_allowvals in ./
autocomplete_widgets.common.inc - Validate a list autocomplete element.
File
- ./
autocomplete_widgets.common.inc, line 31 - Common functions for Autocomplete Widgets module.
Code
function _autocomplete_widgets_get_options($instance, $string = '', $match = 'contains', $keys = NULL, $limit = NULL) {
static $results = array();
// Create unique id for static cache.
if (!isset($keys) || !is_array($keys)) {
$keys = array();
}
$cid = $instance['field_name'] . ':' . $match . ':' . ($string !== '' ? $string : implode('-', $keys)) . ':' . $limit;
if (!isset($results[$cid])) {
switch ($instance['widget']['type']) {
case 'autocomplete_widgets_allowvals':
$results[$cid] = _autocomplete_widgets_get_options_allowvals($instance, $string, $match, $keys, $limit);
break;
case 'autocomplete_widgets_flddata':
$results[$cid] = _autocomplete_widgets_get_options_flddata($instance, $string, $match, $keys, $limit);
break;
case 'autocomplete_widgets_suggested':
$results[$cid] = _autocomplete_widgets_get_options_suggested($instance, $string, $match, $keys, $limit);
break;
case 'autocomplete_widgets_node_reference':
$results[$cid] = _autocomplete_widgets_get_options_node_reference($instance, $string, $match, $keys, $limit);
break;
default:
$results[$cid] = array();
}
}
return $results[$cid];
}