You are here

function term_merge_form_submit in Term Merge 7

Submit handler for term_merge_form(). Merge terms one into another.

File

./term_merge.pages.inc, line 214
Menu page callbacks for Term Merge module.

Code

function term_merge_form_submit($form, &$form_state) {
  if (!isset($form_state['storage']['confirm'])) {

    // Since merging terms is an important operation, we better confirm user
    // really wants to do this.
    $form_state['storage']['confirm'] = 0;
    $form_state['rebuild'] = TRUE;
    $form_state['storage']['info'] = $form_state['values'];
    $form_state['storage']['merge_settings'] = term_merge_merge_options_submit($form, $form_state, $form);
  }
  else {

    // The user has confirmed merging. We pull up the submitted values.
    $form_state['values'] = $form_state['storage']['info'];
    term_merge(array_values($form_state['values']['term_branch']), $form_state['values']['term_trunk']['tid'], $form_state['storage']['merge_settings']);
    $form_state['redirect'] = array(
      'taxonomy/term/' . $form_state['values']['term_trunk']['tid'],
    );
  }
}