Accounts billing address country to dropdown

Hello all!

I’m trying to change the textbox country in Account billing address to dropdown/select. I’ve managed to change it into dropdown but values from dropdown are not pupulated into select box.
What I did so far:

  • copied include/SugarFields/Fields/Address/EditView.tpl to custom/include/SugarFields/Fields/DropdownCountryAddress/EditView.tpl
  • Changed EditView part that renders the country:


<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}}>


<select name="{{$country}}" width="{{$displayParams.size|default:30}}" id="{{$country}}" title="{{$}}" 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}
 {html_options options=$fields.{{$country}}.options selected=$fields.{{$country}}.default_value}
  • Created new file at custom/Extension/modules/Accounts/Ext/Vardefs/custom_billing_address_country.php
    with content:
$dictionary['Accounts']['fields']['billing_address_country']['comments']='Country for billing address';
  • Changed type in custom/modules/Accounts/metadata/editviewdefs.php so it looks like this now:
0 =>
          array (
            'name' => 'billing_address_street',
            'hideLabel' => true,
            'type' => 'DropdownCountryAddress',
            'displayParams' =>.
            array (
              'key' => 'billing',
              'rows' => 2,
              'cols' => 30,
              'maxlength' => 150,

Then I do “Quick Repair and Rebuild” and that’s where it ends. I don’t know what to do next.
“countries_dom” dropdown exists and it’s filled with countries.

Did I forgot anything?

Thank you and kind regards,

I was also wondering why Countries and States are not drop down’s by default. This would make sense in the base deploy.

dmarkic: You have done it correctly apart from one tiny error, change Accounts to Account :wink:

1 Like

Countries makes no sense to me true, but States does, there’s so many countries states in countries that aren’t USA that it would be an insanely huge dataset, and they want to make sure this works internationally.

But countries makes no sense.

Its been that way since the fork from SugarCRM, they probably had a reason for it.

And thus is traditional and should stay that way?

I think not.

I’d love for it to actually have a UI, just a simple checkbox when adding an address field type that let’s you choose whether want dropdown. It can’t be that complex at all.

I’m honestly surprised it wasn’t an option from day one.

is it possible to make state field as drop down and it is shown when i select country field item?

did you create the list in custom/include/language/en_us.lang.php and …es_Es.lang.php?