function clients_connection_form_submit in Web Service Clients 6.2
Same name and namespace in other branches
- 7.3 includes/clients.connection.admin.inc \clients_connection_form_submit()
- 7 clients.connection.admin.inc \clients_connection_form_submit()
- 7.2 clients.connection.admin.inc \clients_connection_form_submit()
Form submit handler for the connection form.
Gets the class of the connection from the data in the form and calls the connectionSettingsForm_submit() method on the class. This allows different behaviour for different connection types, while saving is handled here.
See also
clients_connection_form_validate()
File
- ./
clients.connection.admin.inc, line 200 - clients.connection.admin.inc Page callbacks relating to client connection admin.
Code
function clients_connection_form_submit($form, &$form_state) {
//dsm($form);
//dsm($form_state);
$class = $form['#connection_class'];
$old_connection = $form_state['values']['old_connection'];
// Use call_user_func_array() so form state can be passed by reference.
call_user_func_array(array(
$class,
'connectionSettingsForm_submit',
), array(
$form,
&$form_state,
));
// Common actions for all forms.
$connection = $form_state['values'];
// Connections with no configuration nonetheless need the array.
if (!isset($connection['configuration'])) {
$connection['configuration'] = array();
}
// Add in the cid, if there was one originally.
// Check whether we're editing or adding a new connection.
// We could use $old_connection->new to determine whether this is an insert
// or an update, but that's probably not going to work come CTools, as a
// connection may not be 'new' but may not have a cid if it's from code.
if (isset($old_connection->cid)) {
$connection['cid'] = $old_connection->cid;
drupal_write_record('clients_connections', $connection, 'cid');
}
else {
drupal_write_record('clients_connections', $connection);
}
drupal_set_message(t('Connection saved.'));
$form_state['redirect'] = 'admin/build/clients/connections/' . $connection['name'];
}