function uc_addresses_get_address_form in Ubercart Addresses 5.2
Same name and namespace in other branches
- 5 uc_addresses.module \uc_addresses_get_address_form()
- 6.2 uc_addresses.pages.inc \uc_addresses_get_address_form()
- 6 uc_addresses.module \uc_addresses_get_address_form()
- 7 uc_addresses.pages.inc \uc_addresses_get_address_form()
Create a form used to add a new address or edit an existing address.
Parameters
$address_user The user who "owns" this address.:
$aid The address id for this address (0 for new addresses):
$view The URL path for which form to display. 'new', 'add' or 'edit'.:
Return value
An address form
1 string reference to 'uc_addresses_get_address_form'
- uc_addresses_get_address in ./
uc_addresses.module - Display a form to add a new address or edit a user's addresses.
File
- ./
uc_addresses.module, line 859
Code
function uc_addresses_get_address_form($address_user, $aid, $view) {
// Cancel an address entry when a customer clicks the 'Cancel'
// button.
if (isset($_POST['op'])) {
if ($_POST['op'] == t('Cancel')) {
drupal_goto('user/' . $address_user . '/addresses');
}
if ($_POST['op'] == variable_get('uc_addresses_delete_button', t('Delete address'))) {
cache_clear_all();
drupal_goto('user/' . $address_user . '/addresses/' . $aid . '/delete');
}
}
// Get the panes to display
$form['panes'] = array(
'#tree' => TRUE,
);
$panes = _address_pane_list($view);
foreach ($panes as $pane) {
if (in_array($view, $pane['show']) && variable_get('uc_addresses_pane_' . $pane['id'] . '_show_' . $view, TRUE)) {
if ($aid != NULL) {
$address = _uc_addresses_db_get_address($address_user, $aid);
$return = $pane['callback']($view, $address, NULL);
}
else {
$return = $pane['callback']($view, NULL, NULL);
}
// Add the pane if any display data is returned from the
// callback
if (is_array($return) && (!empty($return['description']) || !empty($return['contents']))) {
// Create the fieldset for the pane
$form['panes'][$pane['id']] = array(
'#type' => 'fieldset',
'#title' => $pane['title'],
'#description' => !empty($return['description']) ? $return['description'] : NULL,
'#collapsible' => !empty($pane['collapsible']) ? $pane['collapsible'] : FALSE,
'#collapsed' => FALSE,
'#attributes' => array(
'id' => $pane['id'] . '-pane',
),
'#theme' => $return['theme'],
);
// Add the contents of the fieldset if any were returned
if (!empty($return['contents'])) {
$form['panes'][$pane['id']] = array_merge($form['panes'][$pane['id']], $return['contents']);
}
}
}
}
$form['cancel'] = array(
'#type' => 'submit',
'#submit' => FALSE,
'#value' => t('Cancel'),
);
// Edit an existing address
if (arg(4) == 'edit') {
$form['delete'] = array(
'#type' => 'submit',
'#value' => variable_get('uc_addresses_delete_button', t('Delete address')),
'#disabled' => $address->is_default,
);
$form['continue'] = array(
'#type' => 'submit',
'#value' => variable_get('uc_addresses_update_button', t('Update address')),
);
}
else {
$form['continue'] = array(
'#type' => 'submit',
'#value' => variable_get('uc_addresses_update_button', t('Add address')),
);
}
$form['#submit'] = array(
'uc_addresses_get_address_form_submit' => array(
$address_user,
$aid,
$view,
),
);
return $form;
}