You are here

function rooms_unit_type_description_source in Rooms - Drupal Booking for Hotels, B&Bs and Vacation Rentals 7

Helper function for Unit Description autocomplete.

1 string reference to 'rooms_unit_type_description_source'
rooms_unit_menu in modules/rooms_unit/rooms_unit.module
Implements hook_menu().

File

modules/rooms_unit/rooms_unit.module, line 591
Manage units - Units are things that can be booked on a nightly basis (e.g. rooms - but also villas bungalows, etc).

Code

function rooms_unit_type_description_source($string = '') {
  $matches = array();
  if ($string) {
    $result = db_select('node', 'n')
      ->fields('n', array(
      'title',
      'nid',
    ))
      ->condition('title', db_like($string) . '%', 'LIKE')
      ->condition('n.type', 'unit_description')
      ->range(0, 10)
      ->execute();
    foreach ($result as $description) {
      $matches[$description->title . ':' . $description->nid] = check_plain($description->title);
    }
  }
  drupal_json_output($matches);
}