case 'world_region':
case 'worldregion':
case 'worldregion_id':
- return CRM_Core_PseudoConstant::worldRegion();
+ return CRM_Core_BAO_Country::buildOptions('region_id', $context);
}
return CRM_Core_PseudoConstant::get(__CLASS__, $fieldName, $params, $context);
}
$field['widget']['required'] = $this->value('required', $fieldXML);
}
}
-
+ if (isset($fieldXML->localize_context)) {
+ $field['localize_context'] = $fieldXML->localize_context;
+ }
$field['pseudoconstant'] = $this->value('pseudoconstant', $fieldXML);
if (!empty($field['pseudoconstant'])) {
//ok this is a bit long-winded but it gets there & is consistent with above approach
*
* Generated from xml/schema/CRM/Core/Address.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:7e4fc550c624fb3f273f3b2f53a23ee3)
+ * (GenCodeChecksum:a81d4789f6650c68145ab9bf1e4481a8)
*/
/**
'entity' => 'Address',
'bao' => 'CRM_Core_BAO_Address',
'localizable' => 0,
+ 'localize_context' => 'province',
'FKClassName' => 'CRM_Core_DAO_StateProvince',
'html' => [
'type' => 'ChainSelect',
'entity' => 'Address',
'bao' => 'CRM_Core_BAO_Address',
'localizable' => 0,
+ 'localize_context' => 'country',
'FKClassName' => 'CRM_Core_DAO_Country',
'html' => [
'type' => 'Select',
*
* Generated from xml/schema/CRM/Core/Country.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:a71fa14f07c9291cf9db0e2335ee4613)
+ * (GenCodeChecksum:467cb92fabf3d936d330591eec94504d)
*/
/**
'entity' => 'Country',
'bao' => 'CRM_Core_BAO_Country',
'localizable' => 0,
+ 'localize_context' => 'country',
'FKClassName' => 'CRM_Core_DAO_Worldregion',
+ 'pseudoconstant' => [
+ 'table' => 'civicrm_worldregion',
+ 'keyColumn' => 'id',
+ 'labelColumn' => 'name',
+ ]
],
'is_province_abbreviated' => [
'name' => 'is_province_abbreviated',
public static function get($daoName, $fieldName, $params = array(), $context = NULL) {
CRM_Core_DAO::buildOptionsContext($context);
$flip = !empty($params['flip']);
+ // Historically this was 'false' but according to the notes in
+ // CRM_Core_DAO::buildOptionsContext it should be context dependent.
+ // timidly changing for 'search' only to fix world_region in search options.
+ $localizeDefault = in_array($context, ['search']) ? TRUE : FALSE;
// Merge params with defaults
$params += array(
'grouping' => FALSE,
- 'localize' => FALSE,
+ 'localize' => $localizeDefault,
'onlyActive' => ($context == 'validate' || $context == 'get') ? FALSE : TRUE,
'fresh' => FALSE,
'context' => $context,
// Localize results
if (!empty($params['localize']) || $pseudoconstant['table'] == 'civicrm_country' || $pseudoconstant['table'] == 'civicrm_state_province') {
$I18nParams = array();
- if ($pseudoconstant['table'] == 'civicrm_country') {
- $I18nParams['context'] = 'country';
- }
- if ($pseudoconstant['table'] == 'civicrm_state_province') {
- $I18nParams['context'] = 'province';
+ if (isset($fieldSpec['localize_context'])) {
+ $I18nParams['context'] = $fieldSpec['localize_context'];
}
$i18n = CRM_Core_I18n::singleton();
$i18n->localizeArray($output, $I18nParams);
<keyColumn>id</keyColumn>
<labelColumn>name</labelColumn>
</pseudoconstant>
+ <localize_context>province</localize_context>
<html>
<type>ChainSelect</type>
</html>
<labelColumn>name</labelColumn>
<nameColumn>iso_code</nameColumn>
</pseudoconstant>
+ <localize_context>country</localize_context>
<html>
<type>Select</type>
</html>
<required>true</required>
<comment>Foreign key to civicrm_worldregion.id.</comment>
<add>1.8</add>
+ <localize_context>country</localize_context>
+ <pseudoconstant>
+ <table>civicrm_worldregion</table>
+ <keyColumn>id</keyColumn>
+ <labelColumn>name</labelColumn>
+ </pseudoconstant>
</field>
<foreignKey>
<name>region_id</name>
'entity' => '{$table.entity}',
'bao' => '{$table.bao}',
'localizable' => {if $field.localizable}1{else}0{/if},
+ {if $field.localize_context}'localize_context' => '{$field.localize_context}',{/if}
{if $field.FKClassName}
'FKClassName' => '{$field.FKClassName}',