'primary_address_street', * 'type' => 'address', * 'displayParams'=>array('key'=>'primary'), * ), * * Where name is set to the field for ACL verification, type is set to 'address' * to override the default field type and the displayParams array includes the key * for the address field. Assumptions are made that the vardefs.php contains address * elements with the corresponding names. There is the optional displayParam index * 'copy' that accepts as value the key of the other address fields. In our * example we may enable copying from the primary address fields with: * * array ( * 'name' => 'altaddress_street', * 'type' => 'address', * 'displayParams'=>array('key'=>'alt', 'copy'=>'primary'), * ), * */ require_once('include/SugarFields/Fields/Base/SugarFieldBase.php'); class SugarFieldAddress extends SugarFieldBase { function getDetailViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) { $this->setup($parentFieldArray, $vardef, $displayParams, $tabindex); global $app_strings; if(!isset($displayParams['key'])) { $GLOBALS['log']->debug($app_strings['ERR_ADDRESS_KEY_NOT_SPECIFIED']); $this->ss->trigger_error($app_strings['ERR_ADDRESS_KEY_NOT_SPECIFIED']); return; } //Allow for overrides. You can specify a Smarty template file location in the language file. if(isset($app_strings['SMARTY_ADDRESS_DETAILVIEW'])) { $tplCode = $app_strings['SMARTY_ADDRESS_DETAILVIEW']; return $this->fetch($tplCode); } return $this->fetch($this->findTemplate('DetailView')); } function getEditViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) { global $app_strings; if(!isset($displayParams['key'])) { $GLOBALS['log']->debug($app_strings['ERR_ADDRESS_KEY_NOT_SPECIFIED']); $this->ss->trigger_error($app_strings['ERR_ADDRESS_KEY_NOT_SPECIFIED']); return; } $displayParams['fields'] = $this->getDisplayParamsForFields($displayParams['key'], $displayParams['module']); $this->setup($parentFieldArray, $vardef, $displayParams, $tabindex); //Allow for overrides. You can specify a Smarty template file location in the language file. if(isset($app_strings['SMARTY_ADDRESS_EDITVIEW'])) { $tplCode = $app_strings['SMARTY_ADDRESS_EDITVIEW']; return $this->fetch($tplCode); } return $this->fetch($this->findTemplate('EditView')); } /** * @param $key - Address group field key (primary, billing, shipping, ...) * @return array - array of fields included in Address group and their vardefs */ private function getDisplayParamsForFields($key, $module) { $bean = BeanFactory::getBean($module); return array( 'street' => $bean->field_defs[$key . '_address_street'], 'city' => $bean->field_defs[$key . '_address_city'], 'state' => $bean->field_defs[$key . '_address_state'], 'postalcode' => $bean->field_defs[$key . '_address_postalcode'], 'country' => $bean->field_defs[$key . '_address_country'], ); } }