You are here

function wsclient_service_form_submit in Web service client 7

Submit callback of the web service description form.

1 string reference to 'wsclient_service_form_submit'
wsclient_service_form in wsclient_ui/wsclient_ui.inc
Provides a form to add, edit and clone web service descriptions.

File

wsclient_ui/wsclient_ui.inc, line 501
WSClient UI - implements service description management and configuration screens.

Code

function wsclient_service_form_submit($form, &$form_state) {
  $service = entity_ui_form_submit_build_entity($form, $form_state);

  // Save global paramters.
  if (isset($form_state['values']['global_parameters'])) {
    $service->global_parameters = array();
    foreach ($form_state['values']['global_parameters']['items'] as $key => $item) {
      if (!empty($item['name'])) {
        $service->global_parameters[$item['name']] = array(
          'default value' => $item['default_value'],
        );
      }
    }
  }

  // Save global header paramters.
  if (isset($form_state['values']['global_header_parameters'])) {
    $service->global_header_parameters = array();
    foreach ($form_state['values']['global_header_parameters']['items'] as $key => $item) {
      if (!empty($item['data_type'])) {
        $service->global_header_parameters[$item['data_type']] = array(
          'name space url' => $item['name_space'],
        );
      }
    }
  }
  $service
    ->save();
  drupal_set_message(t('Web service description %service has been saved.', array(
    '%service' => $service->label,
  )));
  if ($form_state['op'] == 'add') {
    $form_state['redirect'] = WSCLIENT_UI_PATH . '/manage/' . $service->name;
  }
  else {
    $form_state['redirect'] = WSCLIENT_UI_PATH;
  }
}