You are here

function clients_connection_form in Web Service Clients 6.2

Same name and namespace in other branches
  1. 7.3 includes/clients.connection.admin.inc \clients_connection_form()
  2. 7.2 clients.connection.admin.inc \clients_connection_form()

Form builder for editing a connection.

Gets the class of the connection from the data in the form and calls the connectionSettingsForm() method on the class to build the form. This allows different elements for different connection types.

Parameters

$connection: A connection object.

See also

clients_connection_form_validate()

clients_connection_form_submit()

2 string references to 'clients_connection_form'
clients_connection_add in ./clients.connection.admin.inc
Menu callback for adding a new connection.
clients_menu in ./clients.module
Implementation of hook_menu().

File

./clients.connection.admin.inc, line 98
clients.connection.admin.inc Page callbacks relating to client connection admin.

Code

function clients_connection_form(&$form_state, $connection) {
  $form = array();
  $type = $connection->type;
  $class = 'clients_connection_' . $type;
  $form['old_connection'] = array(
    '#type' => 'value',
    '#value' => $connection,
  );

  //dsm($connection);
  $form['type'] = array(
    '#type' => 'textfield',
    '#title' => t('Connection type'),
    '#description' => t('The type of this connection. May not be changed.'),
    '#value' => $connection->type,
    '#size' => 50,
    '#disabled' => TRUE,
  );
  $form['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Connection machine name'),
    '#default_value' => $connection->name,
    '#size' => 50,
    '#maxlength' => 100,
    '#description' => t('The connection name must contain only lowercase letters, numbers, and underscores. It must be unique.'),
    '#required' => TRUE,
  );
  if ($connection->name) {
    $form['name']['#description'] .= '<br /><strong>' . t('Warning: Changing the name of an existing connection may affect any data you have stored based on that connection.') . '</strong>';
  }
  $form['#connection_type'] = $type;
  $form['#connection_class'] = $class;
  $form += $connection
    ->connectionSettingsForm($form_state);
  $form['buttons']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save connection'),
  );
  return $form;
}