I would like to use the address field module in my module. How do I create an address field and an instance for that field. I haven't found any code in the module that defines what the array structure should look like.
I found this code in the commerce module (under modules/customer/commerce_customer.module):
if (empty($field)) {
$field = array(
'field_name' => $field_name,
'type' => 'addressfield',
'cardinality' => 1,
'entity_types' => array('commerce_customer_profile'),
'translatable' => FALSE,
);
$field = field_create_field($field);
}
if (empty($instance)) {
$instance = array(
'field_name' => $field_name,
'entity_type' => 'commerce_customer_profile',
'bundle' => $profile_type['type'],
'label' => t('Address'),
'required' => TRUE,
'widget' => array(
'type' => 'addressfield_standard',
'weight' => -10,
'settings' => array(
'format_handlers' => array('address', 'name-oneline'),
),
),
'display' => array(),
);
I can modify that to meet my needs, if someone is familiar with this module and could point out some attributes that may be missing, I'll accept their response as an answer to this question.
Update The address that I'm importing may contain up to 6 lines for the street address (all for one location) as defined by RETS. Is it possible to store a street address this long in an address field? If not I can concatenate the extra addresses into the second address line.