You are here

function uc_addresses_get_address_form_submit in Ubercart Addresses 7

Same name and namespace in other branches
  1. 5.2 uc_addresses.module \uc_addresses_get_address_form_submit()
  2. 5 uc_addresses.module \uc_addresses_get_address_form_submit()
  3. 6.2 uc_addresses.pages.inc \uc_addresses_get_address_form_submit()
  4. 6 uc_addresses.module \uc_addresses_get_address_form_submit()

Submit handler for the address form.

Return value

void

See also

uc_addresses_get_address_form()

uc_addresses_get_address_form_validate()

1 string reference to 'uc_addresses_get_address_form_submit'
uc_addresses_get_address_form in ./uc_addresses.pages.inc
Creates a form used to add a new address or edit an existing address.

File

./uc_addresses.pages.inc, line 414
Page callbacks for viewing, adding, editing, and deleting addresses.

Code

function uc_addresses_get_address_form_submit(&$form, &$form_state) {
  try {
    $address = $form['uc_addresses']['address']['#uc_addresses_address'];
    if ($form_state['clicked_button']['#value'] == variable_get('uc_addresses_delete_button', t('Delete address'))) {
      $form_state['redirect'] = 'user/' . $address
        ->getUserId() . '/addresses/' . $address
        ->getId() . '/delete';
    }
    elseif ($form_state['clicked_button']['#value']) {
      $address
        ->save();
      drupal_set_message(t('The address is saved.'));
      $form_state['redirect'] = 'user/' . $address
        ->getUserId() . '/addresses';
    }
  } catch (Exception $e) {
    drupal_set_message($e
      ->getMessage(), 'error');
  }
}