You are here

function domain_form_submit in Domain Access 7.3

Same name and namespace in other branches
  1. 6.2 domain.admin.inc \domain_form_submit()
  2. 7.2 domain.admin.inc \domain_form_submit()

Implement domain_form submit hook.

File

./domain.admin.inc, line 561
Administration functions for the domain module.

Code

function domain_form_submit($form, &$form_state) {
  $values = domain_values_from_form_state($form_state);

  // Set the proper message.
  if (!empty($values['domain_id'])) {
    $message = t('Domain record updated.');
  }
  else {
    $message = t('Domain record created.');
  }
  if (!empty($values['is_default'])) {
    $message .= ' ' . t('Set as primary domain.');
  }

  // Run the save routine.
  $domain = domain_save($values, $form_state);

  // If return is not a $domain array, something went wrong.
  if ($domain == -1) {
    $message = t('Domain record failed.');
  }
  else {

    // Update the domain_id in $form_state for any submit handlers that need it.
    if (empty($form_state['values']['domain_id'])) {
      $form_state['values']['domain_id'] = $domain['domain_id'];
    }
  }

  // Hide the message for the Domain User module.
  if (empty($form_state['values']['domain_arguments']['user_submitted'])) {
    drupal_set_message($message);
  }
  return $domain;
}