function uc_addresses_get_address_form_submit in Ubercart Addresses 5.2
Same name and namespace in other branches
- 5 uc_addresses.module \uc_addresses_get_address_form_submit()
- 6.2 uc_addresses.pages.inc \uc_addresses_get_address_form_submit()
- 6 uc_addresses.module \uc_addresses_get_address_form_submit()
- 7 uc_addresses.pages.inc \uc_addresses_get_address_form_submit()
Handle the form submit. If $view is 'edit' run update database function, if 'new' or 'add', run insert database function.
Parameters
$form_id The name of the form.:
$form_values The form array.:
$address_user The user who "owns" the address.:
$aid The address id (0 for new addresses).:
$view Either ''new', 'add' or edit'.:
Return value
The path where we should wind up.
File
- ./
uc_addresses.module, line 990
Code
function uc_addresses_get_address_form_submit($form_id, $form_values, $address_user, $aid, $view) {
global $user;
$address = new stdClass();
$address->uid = $address_user;
$valid = TRUE;
foreach (element_children($form_values['panes']) as $pane_id) {
$func = _address_pane_data($pane_id, 'callback');
$isvalid = $func('process', $address, $form_values['panes'][$pane_id]);
if ($isvalid === FALSE) {
$_SESSION['expanded_panes'][] = $key;
$valid = FALSE;
}
}
if ($view == 'edit') {
// Update database
$address->aid = $aid;
_uc_addresses_db_update_address($address);
}
elseif ($view == 'new' || $view == 'add') {
// Insert into datebase
_uc_addresses_db_add_address($address);
}
return 'user/' . $address->uid . '/addresses';
}