| 1 |
<?php |
<?php |
| 2 |
// $Id: addresses.inc,v 1.19 2008/07/31 11:26:51 brmassa Exp $ |
// $Id: addresses.inc,v 1.20 2008/08/01 04:18:58 brmassa Exp $ |
| 3 |
/** |
/** |
| 4 |
* @author Bruno Massa |
* @author Bruno Massa |
| 5 |
* @file addresses.inc |
* @file addresses.inc |
| 479 |
} |
} |
| 480 |
|
|
| 481 |
/** |
/** |
|
* It returns a list of form fields for a single address. |
|
|
* |
|
|
* @ingroup form |
|
|
* @param &$form_state |
|
|
* Array. The current form structure. |
|
|
* @param $group |
|
|
* String. The variable that contains the group of fields that |
|
|
* will be used on this address. |
|
|
* @param $values |
|
|
* Array (optional). Each key is one of the address fields: 'street', |
|
|
* 'additional', 'city', 'province', 'postal_code', 'country' and each |
|
|
* value is a prefilled value for the given field. |
|
|
* |
|
|
* @return |
|
|
* An address form based on the parameters specified. If the $fields array is empty, then the |
|
|
* function returns a form in which all possible fields are served as optional form items. |
|
|
* |
|
|
* @see _addresses_form_validate() |
|
|
* @see _addresses_form_submit() |
|
|
*/ |
|
|
function _addresses_form(&$form, $fields, $values = array()) { |
|
|
// Generate the Global Address fieldset or only the |
|
|
// form hierarchy |
|
|
if (!empty($fields['master_fieldset'])) { |
|
|
$form['addresses'] = array( |
|
|
'#collapsible' => TRUE, |
|
|
'#collapsed' => TRUE, |
|
|
'#title' => t('Addresses'), |
|
|
'#type' => 'fieldset', |
|
|
); |
|
|
} |
|
|
$form['addresses']['#tree'] = TRUE; |
|
|
|
|
|
// At least one address form should exist |
|
|
if (empty($fields['qty'])) { |
|
|
$fields['qty'] = 1; |
|
|
} |
|
|
|
|
|
for ($a = 1; $a <= $fields['qty']; $a++) { |
|
|
// Address fieldset |
|
|
if (!empty($fields['local_fieldset'])) { |
|
|
$form['addresses'][$a] = array( |
|
|
'#collapsible' => TRUE, |
|
|
'#title' => $a + 1, |
|
|
'#type' => 'fieldset', |
|
|
); |
|
|
} |
|
|
$form['addresses'][$a]['#tree'] = TRUE; |
|
|
|
|
|
// If its a existing address, save the Address ID |
|
|
// for further processing |
|
|
if (!empty($values[$a]['aid'])) { |
|
|
$form['addresses'][$a]['aid'] = array( |
|
|
'#type' => 'hidden', |
|
|
'#value' => $values[$a]['aid'] |
|
|
); |
|
|
} |
|
|
|
|
|
// Get other fields from hook_addressesfieldsapi |
|
|
$form['addresses'] = array_merge( |
|
|
$form['addresses'], |
|
|
module_invoke_all('addressesfieldapi', 'form', $fields, $values) |
|
|
); |
|
|
} |
|
|
|
|
|
return $form; |
|
|
} |
|
|
|
|
|
/** |
|
| 482 |
* Get available states. |
* Get available states. |
| 483 |
* |
* |
| 484 |
* @param $country |
* @param $country |