You are here

function organigrams_form_organigrams_submit in Organigrams 7

Form submit handler for 'organigrams_form_organigrams'.

File

./organigrams.admin.inc, line 498
Defines the administration forms for managing organigrams.

Code

function organigrams_form_organigrams_submit($form, &$form_state) {

  // Retrieve the organigram.
  $organigram = $form_state['organigram'];

  // Submit the organigrams entity.
  entity_form_submit_build_entity('organigrams', $organigram, $form, $form_state);

  // Evaluate the save status.
  switch (organigrams_save($organigram)) {
    case SAVED_NEW:
      drupal_set_message(t('Created new organigram %name.', array(
        '%name' => $organigram->name,
      )));
      watchdog('organigrams', 'Created new organigram %name.', array(
        '%name' => $organigram->name,
      ), WATCHDOG_NOTICE, l(t('edit'), "admin/structure/organigrams/{$organigram->machine_name}/edit"));
      break;
    case SAVED_UPDATED:
      drupal_set_message(t('Updated organigram %name.', array(
        '%name' => $organigram->name,
      )));
      watchdog('organigrams', 'Updated organigram %name.', array(
        '%name' => $organigram->name,
      ), WATCHDOG_NOTICE, l(t('edit'), "admin/structure/organigrams/{$organigram->machine_name}/edit"));
      break;
  }

  // Add organigram information to the form state.
  $form_state['values']['oid'] = $organigram->oid;
  $form_state['oid'] = $organigram->oid;

  // Redirect to the 'admin/structure/organigrams' page.
  $form_state['redirect'] = 'admin/structure/organigrams';
}