}
//make location type required for inline edit
- $form->addSelect("address[$blockId][location_type_id]", array(
- 'entity' => 'address',
- 'class' => 'eight',
- ) + $js, $inlineEdit);
+ $form->addField("address[$blockId][location_type_id]", array('entity' => 'address', 'class' => 'eight') + $js, $inlineEdit);
if (!$inlineEdit) {
$js = array('id' => 'Address_' . $blockId . '_IsPrimary', 'onClick' => 'singleSelect( this.id );');
}
- $form->addElement(
- 'checkbox',
- "address[$blockId][is_primary]",
- ts('Primary location for this contact'),
- ts('Primary location for this contact'),
- $js
- );
+ $form->addField(
+ "address[$blockId][is_primary]", array(
+ 'entity' => 'address',
+ 'label' => ts('Primary location for this contact'),
+ 'text' => ts('Primary location for this contact')) + $js);
if (!$inlineEdit) {
$js = array('id' => 'Address_' . $blockId . '_IsBilling', 'onClick' => 'singleSelect( this.id );');
}
- $form->addElement(
- 'checkbox',
- "address[$blockId][is_billing]",
- ts('Billing location for this contact'),
- ts('Billing location for this contact'),
- $js
- );
+ $form->addField(
+ "address[$blockId][is_billing]", array(
+ 'entity' => 'address',
+ 'label' => ts('Primary location for this contact'),
+ 'text' => ts('Primary location for this contact')) + $js);
// hidden element to store master address id
- $form->addElement('hidden', "address[$blockId][master_id]");
-
+ $form->addField("address[$blockId][master_id]", array('entity' => 'address', 'type' => 'hidden'));
$addressOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'address_options', TRUE, NULL, TRUE
);
$attributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_Address');
$elements = array(
- 'address_name' => array(ts('Address Name'), $attributes['address_name'], NULL),
- 'street_address' => array(ts('Street Address'), $attributes['street_address'], NULL),
- 'supplemental_address_1' => array(ts('Supplemental Address 1'), $attributes['supplemental_address_1'], NULL),
- 'supplemental_address_2' => array(ts('Supplemental Address 2'), $attributes['supplemental_address_2'], NULL),
- 'city' => array(ts('City'), $attributes['city'], NULL),
- 'postal_code' => array(
- ts('Zip / Postal Code'),
- array_merge($attributes['postal_code'], array('class' => 'crm_postal_code')),
- NULL,
- ),
- 'postal_code_suffix' => array(
- ts('Postal Code Suffix'),
- array('size' => 4, 'maxlength' => 12, 'class' => 'crm_postal_code_suffix'),
- NULL,
- ),
- 'country_id' => array(ts('Country'), $attributes['country_id'], 'country'),
- 'state_province_id' => array(ts('State/Province'), $attributes['state_province_id'], NULL),
- 'county_id' => array(ts('County'), $attributes['county_id'], NULL),
- 'geo_code_1' => array(ts('Latitude'), array('size' => 9, 'maxlength' => 12), NULL),
- 'geo_code_2' => array(ts('Longitude'), array('size' => 9, 'maxlength' => 12), NULL),
- 'street_number' => array(ts('Street Number'), $attributes['street_number'], NULL),
- 'street_name' => array(ts('Street Name'), $attributes['street_name'], NULL),
- 'street_unit' => array(ts('Apt/Unit/Suite'), $attributes['street_unit'], NULL),
+ 'address_name',
+ 'street_address',
+ 'supplemental_address_1',
+ 'supplemental_address_2',
+ 'city',
+ 'postal_code',
+ 'postal_code_suffix',
+ 'country_id',
+ 'state_province_id',
+ 'county_id',
+ 'geo_code_1',
+ 'geo_code_2',
+ 'street_number',
+ 'street_name',
+ 'street_unit',
);
- foreach ($elements as $name => $v) {
- list($title, $attributes, $select) = $v;
-
+ foreach ($elements as $name) {
+ //Remove id from name, to allow comparison against enabled addressOtions.
$nameWithoutID = strpos($name, '_id') !== FALSE ? substr($name, 0, -3) : $name;
+ // Skip fields which are not enabled in the address options.
if (empty($addressOptions[$nameWithoutID])) {
$continue = TRUE;
+ //Don't skip street parsed fields when parsing is enabled.
if (in_array($nameWithoutID, array(
'street_number',
'street_name',
continue;
}
}
-
- //build normal select if country is not present in address block
- if ($name == 'state_province_id' && !$addressOptions['country']) {
- $select = 'stateProvince';
+ if ($name == 'address_name') {
+ $name = 'name';
}
- if (!$select) {
- if ($name == 'state_province_id' || $name == 'county_id') {
- $form->addChainSelect("address[$blockId][$name]");
- }
- else {
- if ($name == 'address_name') {
- $name = 'name';
- }
-
- $form->addElement('text',
- "address[$blockId][$name]",
- $title,
- $attributes
- );
- }
- }
- else {
- $form->addElement('select',
- "address[$blockId][$name]",
- $title,
- array('' => ts('- select -')) + CRM_Core_PseudoConstant::$select()
- );
- }
+ $form->addField("address[$blockId][$name]", array('entity' => 'address'));
}
$entityId = NULL;
<default>0</default>
<comment>Is this the primary address.</comment>
<add>2.0</add>
+ <html>
+ <type>CheckBox</type>
+ </html>
</field>
<index>
<name>index_is_primary</name>
<default>0</default>
<comment>Is this the billing address.</comment>
<add>2.0</add>
+ <html>
+ <type>CheckBox</type>
+ </html>
</field>
<index>
<name>index_is_billing</name>
delivery, etc.).
</comment>
<add>1.1</add>
+ <html>
+ <type>Text</type>
+ </html>
</field>
<field>
<name>street_number</name>
<export>true</export>
<comment>Numeric portion of address number on the street, e.g. For 112A Main St, the street_number = 112.</comment>
<add>1.1</add>
+ <html>
+ <type>Text</type>
+ </html>
</field>
<field>
<name>street_number_suffix</name>
<comment>Non-numeric portion of address number on the street, e.g. For 112A Main St, the street_number_suffix = A
</comment>
<add>1.1</add>
+ <html>
+ <type>Text</type>
+ </html>
</field>
<field>
<name>street_number_predirectional</name>
<length>8</length>
<comment>Directional prefix, e.g. SE Main St, SE is the prefix.</comment>
<add>1.1</add>
+ <html>
+ <type>Text</type>
+ </html>
</field>
<field>
<name>street_name</name>
<export>true</export>
<comment>Actual street name, excluding St, Dr, Rd, Ave, e.g. For 112 Main St, the street_name = Main.</comment>
<add>1.1</add>
+ <html>
+ <type>Text</type>
+ </html>
</field>
<index>
<name>index_street_name</name>
<length>8</length>
<comment>St, Rd, Dr, etc.</comment>
<add>1.1</add>
+ <html>
+ <type>Text</type>
+ </html>
</field>
<field>
<name>street_number_postdirectional</name>
<length>8</length>
<comment>Directional prefix, e.g. Main St S, S is the suffix.</comment>
<add>1.1</add>
+ <html>
+ <type>Text</type>
+ </html>
</field>
<field>
<name>street_unit</name>
<export>true</export>
<comment>Secondary unit designator, e.g. Apt 3 or Unit # 14, or Bldg 1200</comment>
<add>1.1</add>
+ <html>
+ <type>Text</type>
+ </html>
</field>
<field>
<name>supplemental_address_1</name>
<dataPattern>/unit|ap(ar)?t(ment)?\s(\d|\w)+/i</dataPattern>
<comment>Supplemental Address Information, Line 1</comment>
<add>1.1</add>
+ <html>
+ <type>Text</type>
+ </html>
</field>
<field>
<name>supplemental_address_2</name>
<dataPattern>/unit|ap(ar)?t(ment)?\s(\d|\w)+/i</dataPattern>
<comment>Supplemental Address Information, Line 2</comment>
<add>1.1</add>
+ <html>
+ <type>Text</type>
+ </html>
</field>
<field>
<name>supplemental_address_3</name>
<length>96</length>
<comment>Supplemental Address Information, Line 3</comment>
<add>1.1</add>
+ <html>
+ <type>Text</type>
+ </html>
</field>
<field>
<name>city</name>
<dataPattern>/^[A-Za-z]+(\.?)(\s?[A-Za-z]+){0,2}$/</dataPattern>
<comment>City, Town or Village Name.</comment>
<add>1.1</add>
+ <html>
+ <type>Text</type>
+ </html>
</field>
<index>
<name>index_city</name>
</foreignKey>
<field>
<name>postal_code_suffix</name>
- <title>Postal Code Suffix</title>
+ <title>Zip / Postal Code Suffix</title>
<type>varchar</type>
<length>12</length>
<import>true</import>
<dataPattern>/\d?\d{4}(-\d{4})?/</dataPattern>
<comment>Store the suffix, like the +4 part in the USPS system.</comment>
<add>1.1</add>
+ <html>
+ <type>Text</type>
+ </html>
</field>
<field>
<name>postal_code</name>
- <title>Postal Code</title>
+ <title>Zip / Postal Code</title>
<type>varchar</type>
<length>12</length>
<import>true</import>
validation.
</comment>
<add>1.1</add>
+ <html>
+ <type>Text</type>
+ </html>
</field>
<field>
<name>usps_adc</name>
<headerPattern>/geo/i</headerPattern>
<comment>Latitude</comment>
<add>1.1</add>
+ <html>
+ <type>Text</type>
+ <size>9</size>
+ </html>
</field>
<field>
<name>geo_code_2</name>
<import>true</import>
<headerPattern>/geo/i</headerPattern>
<add>1.1</add>
+ <html>
+ <type>Text</type>
+ <size>9</size>
+ </html>
</field>
<field>
<name>manual_geo_code</name>
<default>0</default>
<comment>Is this a manually entered geo code</comment>
<add>4.3</add>
+ <html>
+ <type>CheckBox</type>
+ </html>
</field>
<field>
<name>timezone</name>
<length>8</length>
<comment>Timezone expressed as a UTC offset - e.g. United States CST would be written as "UTC-6".</comment>
<add>1.1</add>
+ <html>
+ <type>Text</type>
+ </html>
</field>
<field>
<name>name</name>
<headerPattern>/^location|(l(ocation\s)?name)$/i</headerPattern>
<dataPattern>/^\w+$/</dataPattern>
<add>2.1</add>
+ <html>
+ <type>Text</type>
+ </html>
</field>
<field>
<name>master_id</name>