Trying to change Country field in Accounts/Contacts to Dropdown with countries_dom does not work

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.

I have found Converting Address’ Country Field to a Dropdown from SugarCRM Support site and tried and worked.

Difference is editing en_us.EditView.tpl and also other languages instead of EditView.tpl and not changing anything in …/metadata/editviewdefs.php files(for changing the type of fields).

I see them working for both 4 Country fields of Accounts and Contacts.

Can anybody tell that if this is also a proper way to make this change for SuiteCRM ?

For the first method(SuiteCRM article) I have found that code I used for account and contact vardefs are the same and corrected it, I cannot edit my first post. But even with that correction screen is again broken.

And I have reverted back the change for metada/editviewdefs.php for Accounts and Contacts, so type is still address as default.

And it works like that, so the question is this way OK without editing editviewdefs.php(which seems results to break editing screens).

Hi all,

I have a question for Country Dropdown but for Search Filter.

I have adjusted the code according to the guide and Edit Field of Accounts-Billing Address Country is now drop down and I can correctly set Country as Deutschland and shown as Germany when logged in with English.

But for the Accounts Advanced Filter, Country ( Land in German ) is not changed to dropdown selection like Account Type and I cannot filter countries like typing Deutschland or Österreich when I logged in with German. Country Filter always works with /requires English values for filtering accounts or contacts.

I have already done the actions under Updating the Field Type for List View Filter in https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_9.1/Cookbook/Changing_Address_Country_Field_to_a_Dropdown/#Steps_to_Complete

Have I missed something ? or this guide is not valid for SuiteCRM 7.11.12 ?

Thanks in advance.

hii all,
|

How can i get the office field from the name field which is composed of manyfields such as officefield,organisation field and many more.

Thanks