0
我試圖掛鉤uc_addresses提交函數,但它已經變得非常混亂,非常快。只是要注意,這是對的Ubercart Drupal的6運行,所以我已經分離出的代碼uc_addresses.module,我很感興趣,掛鉤中:hook_alter uc_addresses在Drupal/Ubercart提交函數
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');
}
}
的目標是複製提交的表單值的一部分數據庫。這本身可能是一個問題,因爲我需要確保在將值寫入表之後發生了我的掛鉤。所以我的問題是我的鉤子函數應該是什麼樣子,如果我希望它在這個表單提交後發生?