Hi all,
I do not know if these instructions are still valid: Convert the country text field in SuiteCRM to a drop-down list
I’m using my own server(yet Test) with Centos8, PHP 7.3 and SuiteCRM 7.11.9(updated yesterday from initial 7.11.8 installation).
a. I have created custom_primary_address_country.php in custom/Extension/modules/Accounts/Ext/Vardefs and custom/Extension/modules/Contacts/Ext/Vardefs like below:
<?php
$dictionary['Account']['fields']['primary_address_country']['comments']='Country for primary address';
$dictionary['Account']['fields']['primary_address_country']['group']='primary_address';
$dictionary['Account']['fields']['primary_address_country']['options']='countries_dom';
$dictionary['Account']['fields']['primary_address_country']['type']='enum';
?>
<?php
$dictionary['Contact']['fields']['primary_address_country']['comments']='Country for primary address';
$dictionary['Contact']['fields']['primary_address_country']['group']='primary_address';
$dictionary['Contact']['fields']['primary_address_country']['options']='countries_dom';
$dictionary['Contact']['fields']['primary_address_country']['type']='enum';
?>
and adjusted permissions/owneship of those files like other SuiteCRM files.
b. Copied /include/SugarFields/Fields/Address/EditView.tpl to /custom/include/SugarFields/Fields/CustomAddressCountry/
c. Changed EditView.tpl from
<td>
<input type="text" name="{{$country}}" id="{{$country}}" size="{{$displayParams.size|default:30}}"
{{if !empty($vardef.len)}}maxlength='{{$vardef.len}}'{{/if}}
value='{$fields.{{$country}}.value}' {{if !empty($tabindex)}} tabindex="{{$tabindex}}" {{/if}}>
</td>
to:
<td>
<select name="{{$country}}" width="{{$displayParams.size|default:30}}" id="{{$country}}"
title="{{$vardef.help}}" tabindex="{{$tabindex}}"
{{if isset($displayParams.script)}}{{$displayParams.script}}{{/if}}>
{if isset($fields.{{$country}}.value) && $fields.{{$country}}.value != ''}
{html_options options=$fields.{{$country}}.options selected=$fields.{{$country}}.value}
{else}
{html_options options=$fields.{{$country}}.options selected=$fields.{{$country}}.default_value}
{/if}
</select>
</td>
d. And finally changed /custom/modules/Accounts/metadata/editviewdefs.php and /custom/modules/Contacts/metadata/editviewdefs.php for billing_address_street, shipping_address_street, primary_address_street, alt_address_street, ‘type’ => ‘address’ to ‘type’ => ‘CustomAddressCountry’
After that I have checked with Admin - Studio Accounts and Contacts and see that only the Contacts:primary_address_country changed to DropDown others remain the same:
And interestingly both edit views broken like below:
Any idea to fix it to use Country in Accounts and Contacts with the DropDown ? I suppose code in step c for EditView.tpl has some issues, but could not understand why only Contacts-primary_address_country shown as DropDown(not other three) but both of them broken on screen ?
Thanks in advance.