You are here

function clients_connections_select_options in Web Service Clients 7.2

Same name and namespace in other branches
  1. 6.2 clients.module \clients_connections_select_options()
  2. 7.3 clients.module \clients_connections_select_options()
  3. 7 clients.module \clients_connections_select_options()

FormAPI helper to get a list of clients for a select form element.

Parameters

$types: (optional) Specify a single type or a list of types to include. If omitted, all are returned.

$required: Whether the select element is required.

Return value

Array of options for a FormAPI select element; assumed to be single rather than multiple-valued.

File

./clients.module, line 356
Clients module provides a UI, storage, and an API for handling connections to remote webservices, including those provided by Services module on other Drupal sites.

Code

function clients_connections_select_options($types = array(), $required = TRUE) {
  $options = array();
  if ($required) {
    $options[0] = t('- Please choose -');
  }
  else {
    $options[0] = t('- None selected -');
  }
  foreach (clients_connection_load_all($types) as $name => $connection) {
    $options[$name] = $name;
  }
  return $options;
}