You are here

function entity_autocomplete_element_value in Entity Autocomplete 7

Determines the value for an entity autocomplete form element.

Parameters

$form: The form element whose value is being populated.

$input: The incoming input to populate the form element. If this is FALSE, the element's default value should be returned.

Return value

The data that will appear in the $element_state['values'] collection for this element. Return nothing to use the default.

1 string reference to 'entity_autocomplete_element_value'
entity_autocomplete_element_info in ./entity_autocomplete.module
Implements hook_element_info().

File

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

Code

function entity_autocomplete_element_value($element, $input = FALSE) {
  if (FALSE === $input) {
    return isset($element['#default_value']) ? $element['#default_value'] : '';
  }
  else {
    return isset($input) && strlen($input) ? entity_autocomplete_get_id($input) : '';
  }
}