How to remove primary_address_country from form

We are a small company that only services 2 states within the United States. We have no need to enter a country or any leads, accounts, clients.

How can I go about removing primary_address_country from my form?

wow, nobody know. I really thought I would get an answer on this one.

The problem isn’t that nobody knows, it’s that it is so basic that nobody has the energy to explain… I’m sorry. I’ll give you just a few pointers so you can use Google to find the answers you need.

You need to go into Admin, Studio, to edit your Detail views and Edit views to remove the field.

You will need to do this for each of the modules (Contacts, Accounts, Leads, etc.).

In this particular case, because the field is part of the Address, and the Address is treated specially, you may need to override
/include/SugarFields/Fields/Address/en_us.DetailView.tpl
by creating a similar file in
/custom/include/SugarFields/Fields/Address/en_us.DetailView.tpl

This is trickier, but you will also find examples online.

Good luck

1 Like

Thank you. I did some extensive Google searching and found nothing. Now that I have an idea of what I am searching for I have a better grasp on it thank you. I will research and post what I find.

I simply removed this line in the en_us.DetailView.tpl file:
Line 51 of /include/SugarFields/Fields/Address/en_us.DetailView.tpl
{$fields.{{$displayParams.key}}_address_country.value|escape:‘htmlentitydecode’|escape:‘html’|url2html|nl2br}

And these lines in en_us.EditView.tpl file:
Lines 108-11 in the /include/SugarFields/Fields/Address/en_us.EditView.tpl

{sugar_translate label=‘LBL_COUNTRY’ module=’{{$module}}’}:
{if $fields.{{$country}}.required || {{if $country|lower|in_array:$displayParams.required}}true{{else}}false{{/if}}}
{$APP.LBL_REQUIRED_SYMBOL}
{/if}

Saved each file

I had to create new directories in the include folder in order to make this custom proof. I had to create SugarFields, Fields, and Address folders.

Made a copy of each file and saved each of them in the Address folder with the following architecture:
/custom/include/SugarFields/Fields/Address/en_us.DetailView.tpl
/custom/include/SugarFields/Fields/Address/en_us.EditView.tpl

Sure it was simple. I think writing this up took longer!

2 Likes

This worked well for me,

I’d like to add that it’s safer to copy the files to the custom folder first, and then edit them there. Don’t edit the core files, but rather extend them.

1 Like