function tripal_cv_cv_edit_form_submit

2.x tripal_cv.cv_form.inc tripal_cv_cv_edit_form_submit($form, &$form_state)
3.x tripal_chado.cv.inc tripal_cv_cv_edit_form_submit($form, &$form_state)

Submit cv edit form

Related topics

File

tripal_cv/includes/tripal_cv.cv_form.inc, line 204
Provides a form for creating & editing chado controlled vocabularies

Code

function tripal_cv_cv_edit_form_submit($form, &$form_state) {
  $name = array_key_exists('name', $form_state['values']) ? trim($form_state['values']['name']) : '';
  $desc = array_key_exists('definition', $form_state['values']) ? trim($form_state['values']['definition']) : '';
  $cv_id = array_key_exists('cv_id', $form_state['values']) ? trim($form_state['values']['cv_id']) : '';
  $op = array_key_exists('op', $form_state['values']) ? trim($form_state['values']['op']) : '';

  $values = array(
    'name' => $name,
    'definition' => $desc,
  );
  if (strcmp($op, 'Update') == 0) {
    $match = array('cv_id' => $cv_id);
    $success = chado_update_record('cv', $match, $values);
    if ($success) {
      drupal_set_message(t("Controlled vocabulary updated"));
    }
    else {
      drupal_set_message(t("Failed to update controlled vocabulary."));
    }
  }
  if (strcmp($op, 'Delete') == 0) {
    $match = array('cv_id' => $cv_id);
    $success = chado_delete_record('cv', $match);
    if ($success) {
      drupal_set_message(t("Controlled vocabulary deleted"));
    }
    else {
      drupal_set_message(t("Failed to delete controlled vocabulary."));
    }
  }
}