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:

From:

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

To:

<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>
  • Created new file at custom/Extension/modules/Accounts/Ext/Vardefs/custom_billing_address_country.php
    with content:
<?php
$dictionary['Accounts']['fields']['billing_address_country']['comments']='Country for billing address';
$dictionary['Accounts']['fields']['billing_address_country']['group']='billing_address';
$dictionary['Accounts']['fields']['billing_address_country']['options']='countries_dom';
$dictionary['Accounts']['fields']['billing_address_country']['type']='enum';
?>
  • 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,
Dejan

Found the errror.
I had a typo here:

<?php
$dictionary['Accounts']['fields']['billing_address_country']['comments']='Country for billing address';
$dictionary['Accounts']['fields']['billing_address_country']['group']='billing_address';
$dictionary['Accounts']['fields']['billing_address_country']['options']='countries_dom';
$dictionary['Accounts']['fields']['billing_address_country']['type']='enum';
?>

Changed “Accounts” to “Account” and it’s working now.

New:

$dictionary['Account']['fields']['billing_address_country']['comments']='Country for billing address';
$dictionary['Account']['fields']['billing_address_country']['group']='billing_address';
$dictionary['Account']['fields']['billing_address_country']['options']='countries_dom';
$dictionary['Account']['fields']['billing_address_country']['type']='enum';

Kind regards,
Dejan

Hi,

Give path i am not found the dropdown country tpl not found

Can guide where i have get this tpl & use this solutions.

Thanks in advance.

Nitesh V shah

Here is your answer:

http://stackoverflow.com/questions/15475553/change-country-textfield-to-dropdown-in-sugarcrm