Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: Country dropdown list (5.0GA)

  1. #1
    john30043 is offline Sugar Community Member
    Join Date
    Nov 2007
    Location
    Atlanta, GA
    Posts
    17

    Default Country dropdown list (5.0GA)

    I just installed 5.0 GA and noticed a small change... For billing address when setup an account, it used to have a dropdown list for countries, in 5.0GA, it's a free text field now. Is there any reason to remove the dropdown list? in studio/dropdown editor, there is still a 'countries_dom', where is it used?
    Last edited by john30043; 2007-12-18 at 02:43 PM.
    John Zhang
    [Server: WinXP]
    [Sugar v5.0.0 GA]
    [Apache 2.2.5]
    [MySQL 5.0.45]

  2. #2
    andydreisch's Avatar
    andydreisch is offline Sugar Team Member
    Join Date
    Apr 2005
    Location
    San Jose
    Posts
    2,080

    Default Re: Country dropdown list (5.0GA)

    Hi john30043, let me look into this.

    Andy
    Andy Dreisch
    Vice President, Online Team


    Check out our Podcasts!
    Sugar University for training
    Sugar Wiki for developer and user help
    SugarForge for modules, themes, lang packs
    SugarExchange for production-ready extensions
    Enter/view bugs via the Sugar bug tracker

  3. #3
    beuten is offline Sugar Community Member
    Join Date
    May 2006
    Location
    Berlin, Germany
    Posts
    151

    Default Re: Country dropdown list (5.0GA)

    Happy New Year everyone!

    Andy,
    did you find anything out regarding this one?
    Chad (beuten)
    DAXTEN
    www.daxten.com

  4. #4
    PProhaska is offline Junior Member
    Join Date
    Aug 2007
    Posts
    2

    Default Re: Country dropdown list (5.0GA)

    greetings,

    sugar support told me that the shipping/billing address COUNTRY field will change to a dropdown field
    ...........................in the next version 5.1

    ok..... i cant wait for some weeks: does anyone know the solution for that or even
    can tell me the link to that '5.00 GA' version with that feature enabled ?

    regards

    Peter




    ************************************************** *********
    wow! if we knew that all - we would be sugar-developers
    and work in sunny san francisco bay - hurray!
    ************************************************** *********

  5. #5
    thierry.beeckmans is offline Sugar Community Member
    Join Date
    Feb 2007
    Posts
    55

    Default Re: Country dropdown list (5.0GA)

    I took a look into the 5.1RC1 code, the functionality doesn't seem to be included.
    I'm also needing that drop-down field, so I'll start to digg into it.

  6. #6
    malcolmh's Avatar
    malcolmh is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Aug 2004
    Posts
    1,712

    Default Re: Country dropdown list (5.0GA)

    Hi,

    I still don't understand why this function isn't available. In one of the 5.0 RC versions the functionality was there, then it disappeared in the GA version.

    The country values are available in the language files (also in 5.1RC). We have already translated the values to German.

    Could someone from Sugar please respond to this thread.
    Cheers Malcolm

    Genius4U Limited - Ingenious simple IT solutions for you / Genial einfache IT Lösungen für Sie
    http://www.genius4u.com or http://www.genius4u.de

  7. #7
    tenetor is offline Junior Member
    Join Date
    Oct 2006
    Posts
    3

    Exclamation Re: Country dropdown list (5.0GA)

    I need this dropdown too ASAP

    If you can find a quick solution to implement it not having to wait for a future version I will be very thankful.

    Juan

  8. #8
    beuten is offline Sugar Community Member
    Join Date
    May 2006
    Location
    Berlin, Germany
    Posts
    151

    Default Re: Country dropdown list (5.0GA)

    Quote Originally Posted by malcolmh
    Could someone from Sugar please respond to this thread.
    Several of us have tried to get someone to reply, but still no answer. Andy said last year that he was looking into it. Maybe it is worth a PM to him?! Will you do that Malcolm?!?
    Chad (beuten)
    DAXTEN
    www.daxten.com

  9. #9
    gregwatson is offline Sugar Community Member
    Join Date
    Sep 2007
    Posts
    20

    Default Re: Country dropdown list (5.0GA)

    I've actually changed it manually (in 5.0f), but it was somewhat of a hack and definitely not upgrade safe, so I have mixed feelings about encouraging anyone to try and copy what I did. That being said, here's what I did; you're mileage may vary.

    The key file involved is (for the US edition) /include/SugarFields/Fields/Address/en_us.EditView.tpl. For non-US users, I assume you change the file in the same folder named EditView.tpl.

    In this file I found the line that creates the country field as a standard text input and commented it out like this:

    Code:
    {*<input type="text" name="{{$country}}" id="{{$country}}" size="{{$displayParams.size|default:30}}" 
    {{if !empty($vardef.len)}}maxlength='{{$vardef.len}}'{{/if}}
     value='{$fields.{{$country}}.value}' tabindex="{{$tabindex}}">*}
    I then added this instead:

    Code:
    <select name="{{$country}}"
     		id="{{$country}}"
     		title='{{$vardef.help}}' 
    		tabindex="{{$tabindex}}"
    {{if isset($displayParams.javascript)}}
    {{$displayParams.javascript}}
    {{/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>
    Now you need to make sure Sugar treats the country field as a dropdown (enum) and knows which list to use. You can do this in a fast, non-upgrade-safe way, or the slower way. The non-upgrade-safe way is to go to /include/SugarObjects/templates/person/vardefs.php and modify the definitions of primary_address_country and alt_address_country. I played it safe and did the upgrade-safe modification instead. It means you have to create a file for each module you want to change. For example, for the Leads module I made a file called /custom/Extension/modules/Leads/Vardefs/custom.php. and added this code. The key changes are making the type = enum and adding an 'options' value:

    PHP Code:
    $dictionary['Lead']['fields']['primary_address_country'] =
            array (
                
    'name' => 'primary_address_country',
                
    'vname' => 'LBL_PRIMARY_ADDRESS_COUNTRY',
                
    'type' => 'enum',
                
    'options' => 'countries_dom',
                
    'group'=>'primary_address',
                
    'comment' => 'Country for primary address',
                
    'merge_filter' => 'enabled',
                );
                
    $dictionary['Lead']['fields']['alt_address_country'] =
            array (
                
    'name' => 'alt_address_country',
                
    'vname' => 'LBL_ALT_ADDRESS_COUNTRY',
                  
    'type' => 'enum',
                
    'options' => 'countries_dom',
                
    'group'=>'alt_address',
                
    'comment' => 'Country for alternate address',
                
    'merge_filter' => 'enabled',
            ); 
    You will now need to repeat/adapt this change for any other modules (like Contacts) that you want to modify. Keep in mind that the Accounts module doesn't use the 'primary_' and 'alternate_' prefixes, but 'billing_' and 'shipping_' instead.

    One other thing to change is the checkbox that lets you copy from one address to the other -- it doesn't work with dropdown fields. To be honest I find this feature fairly useless, so one easy option is to disable it. You do this by commenting out the last section of the en_us.EditView.tpl file that starts "{{if $displayParams.copy}} ...".

    If you're feeling more daring, you can do what I did and replace the copy-as-you-type checkbox with a click-and-copy button. To do this, instead of commenting out the code as above, replace it with this:

    Code:
    {{if $displayParams.copy}}
    <tr>
    <td width='{{$def.templateMeta.widths[$smarty.foreach.colIteration.index].label}}%' class="dataLabel" NOWRAP>
    {*{sugar_translate label='LBL_COPY_ADDRESS_FROM_LEFT' module=''}:*}
    <input style='background-color:#D4D0C8;' type="button" value="Copy Primary Address" onclick="syncFields('{{$displayParams.copy}}', '{{$displayParams.key}}');">
    {*<input id="{{$displayParams.key}}_checkbox" name="{{$displayParams.key}}_checkbox" type="checkbox" onclick="syncFields('{{$displayParams.copy}}', '{{$displayParams.key}}');"; CHECKED>
    *}
    </td>
    </tr>
    {{else}}
    <tr>
    <td colspan="2">&nbsp;</td>
    </tr>
    {{/if}}

    Now change the first line of this file so it points to the custom javascript file we're about to create:
    HTML Code:
    <script src="include/SugarFields/Fields/Address/SugarFieldAddress_cust.js" language="javascript"></script>


    Now create a file in the same folder at the tpl file called "SugarFieldAddress_cust.js". Paste this code in:
    HTML Code:
    var elems=new Array("address_street", "address_city", "address_state", "address_postalcode","address_country");
    
    function writeToSyncField(e){
    	fromEl=YAHOO.util.Event.getTarget(e,true);
    
    	if(typeof fromEl!="undefined"){
    		toEl=document.getElementById(fromEl.id.replace(fromKey,toKey));
    		toEl.value=fromEl.value;
    	}
    }
    
    
    function syncFields(fromKey,toKey){
    	for(x in elems){
    		f=fromKey+"_"+elems[x];
    		e2=document.getElementById(f);
    		t=toKey+"_"+elems[x];
    		e1=document.getElementById(t);
    		
    		if (e2.tagName == "SELECT") {
    			e1.selectedIndex = e2.selectedIndex;
    		} else {
    			e1.value = e2.value;
    		}
    		
    	}
    }
    Although this seems to work for me just fine, I want to stress I haven't done extensive testing on different platforms/browsers and these changes will be blown away on the next update that changes the en_us.EditView.tpl file. Also, if your country list has labels that are different from the values, the list view and detail view will show the value rather than the label.

    I hope this helps out,
    Greg Watson

  10. #10
    beuten is offline Sugar Community Member
    Join Date
    May 2006
    Location
    Berlin, Germany
    Posts
    151

    Default Re: Country dropdown list (5.0GA)

    I also just found this in the Wiki Changing Country Fields to Dropdown . I am not sure if it will work in 5.0.0 (has anyone tried it???), but it seems to work in 4.5.1
    Chad (beuten)
    DAXTEN
    www.daxten.com

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Related Dropdown List (conditioned)
    By nramirezf in forum Feature Requests
    Replies: 6
    Last Post: 2008-02-03, 11:01 AM
  2. populate dropdown list from database
    By ashley07 in forum Help
    Replies: 1
    Last Post: 2007-10-18, 09:58 PM
  3. Replies: 5
    Last Post: 2006-12-15, 10:13 AM
  4. Dropdown list
    By sridhar in forum Help
    Replies: 0
    Last Post: 2006-08-18, 01:54 PM
  5. Replies: 3
    Last Post: 2006-06-30, 08:43 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •