Results 1 to 9 of 9

Thread: Change an attribute from TextField to DropDown

  1. #1
    jbarzuna is offline Senior Member
    Join Date
    Dec 2008
    Posts
    26

    Default Change an attribute from TextField to DropDown

    Hello,

    I wanted to know which is the best way to convert a field (the Department field on the Contacts' module, for example) from being an open TextField to a DropDown with a predefined list.

    I know I can create a new custom field and give it the same label and then change the layout to use the new custom field instead of the old one, but is this upgrade-safe? Will it break if I install new modules?

    Thank you very much for your time,

  2. #2
    eggsurplus's Avatar
    eggsurplus is offline Sugar Community Member
    Join Date
    Dec 2005
    Location
    Minnesota
    Posts
    2,343

    Default Re: Change an attribute from TextField to DropDown

    I'd suggest the custom field route as that is more upgrade safe than changing an existing field as that'll get overwritten in any update. Any custom changes in Studio in regards to adding fields will not get overwritten in a future update.

  3. #3
    jbarzuna is offline Senior Member
    Join Date
    Dec 2008
    Posts
    26

    Default Re: Change an attribute from TextField to DropDown

    I have been learning more and more on programming with the studio, however, it seems that if I have to replace every existing field in the database for custom fields in order to create the drop downs then I would end up with a database with twice as many fields, isn't there a way to just make a regular field a pull down field?
    Regards,
    Jose

  4. #4
    christianknoll's Avatar
    christianknoll is offline Sugar Community Member
    Join Date
    Nov 2008
    Location
    Vienna
    Posts
    939

    Default Re: Change an attribute from TextField to DropDown

    create a file named department.enum.php (or any other name you want as long as it ends with .php) in directory custom/Extension/modules/Contacts/Ext/Vardefs with the following content:

    <?php
    $dictionary['Contact']['fields']['department']['type'] = 'enum';
    $dictionary['Contact']['fields']['department']['options'] = 'your_dropdown_that_you_created_before';
    ?>

    Repair Contacts and you are on your way. Thi is the wa better solution than creating custom fields. And it is 100% upgerade safe ... ;-) ...

    christian.

    Quote Originally Posted by jbarzuna View Post
    Hello,

    I wanted to know which is the best way to convert a field (the Department field on the Contacts' module, for example) from being an open TextField to a DropDown with a predefined list.

    I know I can create a new custom field and give it the same label and then change the layout to use the new custom field instead of the old one, but is this upgrade-safe? Will it break if I install new modules?

    Thank you very much for your time,

  5. #5
    yorkylad is offline Sugar Community Member
    Join Date
    Jul 2006
    Posts
    11

    Default Re: Change an attribute from TextField to DropDown

    Quote Originally Posted by christianknoll View Post
    create a file named department.enum.php (or any other name you want as long as it ends with .php) in directory custom/Extension/modules/Contacts/Ext/Vardefs with the following content:

    <?php
    $dictionary['Contact']['fields']['department']['type'] = 'enum';
    $dictionary['Contact']['fields']['department']['options'] = 'your_dropdown_that_you_created_before';
    ?>

    Repair Contacts and you are on your way. Thi is the wa better solution than creating custom fields. And it is 100% upgerade safe ... ;-) ...

    christian.
    NIce idea, seems to work for title as well.

    Tried this to change the primary_address_country, this doesn't work. Any ideas?

    Yorky Lad

  6. #6
    crmbalah is offline A Prolific Poster
    Join Date
    Mar 2009
    Location
    chennai
    Posts
    418

    Default Re: Change an attribute from TextField to DropDown

    HI
    go to include/SugarFields/Fields/Address /EditView.tpl customize the file.

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

    Default Re: Change an attribute from TextField to DropDown

    Quote Originally Posted by crmbalah View Post
    HI
    go to include/SugarFields/Fields/Address /EditView.tpl customize the file.
    I am not sure how to do this request, but your proposed solution is not upgrade safe I think
    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

  8. #8
    andopes's Avatar
    andopes is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Jul 2006
    Location
    São Paulo - Brazil
    Posts
    8,335

    Default Re: Change an attribute from TextField to DropDown

    Quote Originally Posted by malcolmh View Post
    I am not sure how to do this request, but your proposed solution is not upgrade safe I think
    Actually it is not an upgrade safe approach.

    According the Address Field template class:

    PHP Code:
        function getEditViewSmarty($parentFieldArray$vardef$displayParams$tabindex) {
            
    $this->setup($parentFieldArray$vardef$displayParams$tabindex);        
            global 
    $app_strings;
            if(!isset(
    $displayParams['key'])) {
               
    $GLOBALS['log']->debug($app_strings['ERR_ADDRESS_KEY_NOT_SPECIFIED']);    
               
    $this->ss->trigger_error($app_strings['ERR_ADDRESS_KEY_NOT_SPECIFIED']);
               return;
            }
            
            
    //Allow for overrides.  You can specify a Smarty template file location in the language file.
            
    if(isset($app_strings['SMARTY_ADDRESS_EDITVIEW'])) {
               
    $tplCode $app_strings['SMARTY_ADDRESS_EDITVIEW'];
               return 
    $this->fetch($tplCode);    
            }       

            global 
    $current_language;
            if(isset(
    $current_language) && file_exists('include/SugarFields/Fields/Address/' $current_language '.EditView.tpl')) {
              return 
    $this->fetch('include/SugarFields/Fields/Address/' $current_language '.EditView.tpl');     
            } else {
              return 
    $this->fetch('include/SugarFields/Fields/Address/EditView.tpl');
            } 
    //if-else
           
        

    If you create the file <$current_language>.EditView.tpl this one will be loaded instead of the default one.

    Cheers
    André Lopes
    DevToolKit / Project of the Month - June 2009
    Lampada Global Services- Open Source Solutions
    Avenida Ipiranga, 318
    Bloco B - CJ 1602
    São Paulo, SP 01046-010
    Brazil
    Office: +55 11 3237-3110
    Mobile: +55 11 7636-5859
    e-mail: andre@lampadaglobal.com

    Lampada Global delivers offshore software development and support services to customers around the world.
    Lampada is proud to be a SugarCRM Gold Partner, revolutionizing Customer Relationship Management.

    I DO NOT answer questions through PM and Email. If you need some help post your question into SugarForum.

  9. #9
    jbarzuna is offline Senior Member
    Join Date
    Dec 2008
    Posts
    26

    Default Re: Change an attribute from TextField to DropDown

    Hello,

    Thanks for your help, I will be testing your suggestions for a few days.

    Best Regards,
    José

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How to change DB values for this DropDown
    By fai.hans in forum Help
    Replies: 2
    Last Post: 2008-04-03, 10:25 PM
  2. TextField in DropDown umwandeln
    By stefan2309 in forum Deutsche
    Replies: 3
    Last Post: 2008-03-11, 07:02 AM
  3. Plz help me !!! how can I use readonly attribute
    By tinatran in forum General Discussion
    Replies: 2
    Last Post: 2008-02-14, 11:20 PM
  4. How to change the default dropdown value
    By rustinp77 in forum Help
    Replies: 5
    Last Post: 2007-07-02, 06:13 PM
  5. change subpanel select button with a AJAX + textfield
    By sugarcare in forum Developer Help
    Replies: 0
    Last Post: 2006-09-05, 03:57 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
  •