You are here

function entity_autocomplete_get_id in Entity Autocomplete 7

Extract an ID from a string returned by one of the autocomplete callbacks.

Parameters

$value: A string of the form "title [id:ID]" or an integer.

Return value

The extracted ID.

3 calls to entity_autocomplete_get_id()
EntityAutocompleteWebTestCase::testLabelAndID in tests/entity_autocomplete.test
Tests label creation and ID extraction.
entity_autocomplete_element_validate in ./entity_autocomplete.module
Validate an entity autocomplete element.
entity_autocomplete_element_value in ./entity_autocomplete.module
Determines the value for an entity autocomplete form element.

File

./entity_autocomplete.module, line 112
Provides functionalities for entity fields autocompletion.

Code

function entity_autocomplete_get_id($value) {
  return is_numeric($value) ? $value : preg_replace('/.*\\[id:(.*)\\].*/', '${1}', $value);
}