function uc_addresses_get_address_form in Ubercart Addresses 6
Same name and namespace in other branches
- 5.2 uc_addresses.module \uc_addresses_get_address_form()
- 5 uc_addresses.module \uc_addresses_get_address_form()
- 6.2 uc_addresses.pages.inc \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
$form_state The form state.:
$address_user The user who "owns" this address.:
$address The address to edit (NULL for new addresses):
$view The URL path for which form to display. 'add' or 'edit'.:
Return value
An address form
1 string reference to 'uc_addresses_get_address_form'
- uc_addresses_menu in ./
uc_addresses.module - Implementation of hook_menu().
File
- ./
uc_addresses.module, line 917
Code
function uc_addresses_get_address_form(&$form_state, $address_user, $address, $view) {
$uid = $address_user->uid;
$aid = $address ? $address->aid : 0;
$form['stored_values'] = array(
'#type' => 'value',
'#value' => array(
'user' => $address_user,
'address' => $address,
'view' => $view,
),
);
// 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)) {
$return = $pane['callback']($view, $address, 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'],
// Output is already sanitized through t().
'#description' => !empty($return['description']) ? $return['description'] : NULL,
// Output is already sanitized through t().
'#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']);
}
}
}
}
// Edit an existing address
if ($view == 'edit') {
$form['submit'] = array(
'#type' => 'submit',
'#value' => variable_get('uc_addresses_update_button', t('Update address')),
);
$form['delete'] = array(
'#type' => 'submit',
'#value' => variable_get('uc_addresses_delete_button', t('Delete address')),
'#suffix' => l(t('Cancel'), 'user/' . $uid . '/addresses/'),
'#disabled' => $address->is_default,
);
}
else {
$form['submit'] = array(
'#type' => 'submit',
'#value' => variable_get('uc_addresses_update_button', t('Add address')),
'#suffix' => l(t('Cancel'), 'user/' . $uid . '/addresses/'),
);
}
return $form;
}