You are here

function uc_addresses_get_address_form_submit in Ubercart Addresses 5

Same name and namespace in other branches
  1. 5.2 uc_addresses.module \uc_addresses_get_address_form_submit()
  2. 6.2 uc_addresses.pages.inc \uc_addresses_get_address_form_submit()
  3. 6 uc_addresses.module \uc_addresses_get_address_form_submit()
  4. 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.:

$uid 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 960

Code

function uc_addresses_get_address_form_submit($form_id, $form_values, $uid, $aid, $view) {
  global $user;
  $address = new stdClass();
  $address->uid = $uid;
  $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
    _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';
}