function uc_addresses_get_address_form_submit in Ubercart Addresses 6
Same name and namespace in other branches
- 5.2 uc_addresses.module \uc_addresses_get_address_form_submit()
- 5 uc_addresses.module \uc_addresses_get_address_form_submit()
- 6.2 uc_addresses.pages.inc \uc_addresses_get_address_form_submit()
- 7 uc_addresses.pages.inc \uc_addresses_get_address_form_submit()
Handle the form submit for adding a new address or editing an existing address.
Parameters
$form The form.:
$form_state The form state.:
Return value
The path where we should wind up.
File
- ./
uc_addresses.module, line 1036
Code
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',
);
}
}