function rooms_availability_reference_autocomplete_value in Rooms - Drupal Booking for Hotels, B&Bs and Vacation Rentals 7
Value callback for a rooms_availability_reference autocomplete element.
Replace the unit id with a unit name.
1 string reference to 'rooms_availability_reference_autocomplete_value'
- rooms_availability_reference_field_widget_form in modules/
rooms_availability_reference/ rooms_availability_reference.module - Implements hook_field_widget_form().
File
- modules/
rooms_availability_reference/ rooms_availability_reference.module, line 404 - Defines a field type for referencing availability information
Code
function rooms_availability_reference_autocomplete_value($element, $input = FALSE, $form_state) {
if ($input === FALSE) {
// We're building the displayed 'default value': expand the raw unit id into
// "unit name [unit_id:n]".
$unit_id = $element['#default_value'];
if (!empty($unit_id)) {
$unit = rooms_unit_load($unit_id);
$value = $unit->name;
$value .= ' [unit_id:' . $unit_id . ']';
return $value;
}
}
}