function wsconfig_edit_form_submit in Web Service Data 7
Form API submit callback for the wsconfig form.
@todo remove hard-coded link
1 string reference to 'wsconfig_edit_form_submit'
- wsconfig_edit_form in modules/
wsconfig/ wsconfig.admin.inc - Form callback: create or edit a wsconfig.
File
- modules/
wsconfig/ wsconfig.admin.inc, line 254 - Admin forms for wsconfig
Code
function wsconfig_edit_form_submit(&$form, &$form_state) {
$wsconfig = entity_ui_controller('wsconfig')
->entityFormSubmitBuildEntity($form, $form_state);
$wsconfig->data['cache_default_time'] = (int) $form_state['values']['cache_default_time'];
$wsconfig->data['cache_default_override'] = (int) $form_state['values']['cache_default_override'];
$wsconfig->data['stale_cache'] = (int) $form_state['values']['stale_cache'];
// Save the wsconfig and go back to the list of wsconfigs
foreach ($wsconfig
->getOperations() as $operation) {
$op = $wsconfig
->getMethodKey($operation);
$wsconfig->data[$op] = $wsconfig->{$op};
// Save the defined options if any
if (!empty($form_state['values'][$op . '_options'])) {
$wsconfig->data['options'][$op] = drupal_json_decode($form_state['values'][$op . '_options']);
}
}
if ($form_state['triggering_element']['#id'] == 'edit-addmethod-submit') {
$methodname = '';
$name = 'addmethod_name_' . $form_state['values']['addmethod'];
if (isset($form[$name])) {
$methodname = $form_state['values'][$name];
}
$wsconfig
->addMethod($form_state['values']['addmethod'], $methodname);
drupal_set_message(t('Added !METHOD', array(
'!METHOD' => $form_state['values']['addmethod'],
)));
}
$new_wsconfig = FALSE;
// Add in created and changed times.
if (isset($wsconfig->is_new) and $wsconfig->is_new) {
$new_wsconfig = TRUE;
$wsconfig->created = time();
}
$wsconfig->changed = time();
$wsconfig
->save();
if ($new_wsconfig or $form_state['triggering_element']['#id'] == 'edit-addmethod-submit') {
$form_state['redirect'] = 'admin/structure/wsconfig/manage/' . $wsconfig->wsconfig_id . '/edit';
}
else {
drupal_set_message(t('WsConfig saved'));
$form_state['redirect'] = 'admin/structure/wsconfig';
}
}