0

我正在尝试挂钩uc_addresses提交功能,但它很快就变得非常混乱。请注意,这是在 Drupal 6 上运行的 Ubercart。所以我已经隔离了uc_addresses.module中我感兴趣的代码:

function uc_addresses_get_address_form_submit($form, &$form_state) {
  global $user;

  $address_user = $form['stored_values']['#value']['user'];
  $address = $form['stored_values']['#value']['address'];
  $view = $form['stored_values']['#value']['view'];

  if ($form_state['clicked_button']['#value'] == t('Delete address')) {
      cache_clear_all();
      $form_state['redirect'] =
    array('user/'. $address_user->uid .'/addresses/' . $address->aid . '/delete');
  }
  else {
    if (!$address) {
      $address = new stdClass();
      $address->uid = $address_user->uid;
    }

    $valid = TRUE;
    foreach (element_children($form_state['values']['panes']) as $pane_id) {
      $func = _address_pane_data($pane_id, 'callback');
      $isvalid = $func('process', $address, $form_state['values']['panes'][$pane_id]);
      if ($isvalid === FALSE) {
    $_SESSION['expanded_panes'][] = $key;
    $valid = FALSE;
      }
    }
    if ($view == 'edit') { // Update database
      _uc_addresses_db_update_address($address);
    }
    elseif ($view == 'new' || $view == 'add') { // Insert into datebase
      _uc_addresses_db_add_address($address);
    }
    $form_state['redirect'] = array('user/'. $address_user->uid .'/addresses');
  }
}

目标是复制数据库中提交的表单值的一部分。这本身可能是一个问题,因为我需要确保在将值写入表之后发生我的钩子。所以我的问题是,如果我希望在提交此表单后发生钩子函数,我的钩子函数应该是什么样子?

4

1 回答 1

0

好吧,太愚蠢了,我没有意识到 uc_addresses 文档中有很大一部分是关于钩子的。链接到文档。在这种特定情况下,如果您想挂钩表单提交,我建议您使用hook_uc_addresses_address_insert()and hook_uc_addresses_address_update()

于 2012-12-13T16:27:29.940 回答