Results 1 to 10 of 10

Thread: How to turn a text field into a drop down

  1. #1
    buckalec is offline Junior Member
    Join Date
    Aug 2008
    Posts
    1

    Default How to turn a text field into a drop down

    HI - new to sugar and hit a bit of a wall.

    How can I edit the data type for "Title;" and "Department" from text field to be drop downs?

    I've also created custom new drop downs but don't seem to be able to edit the layout in the "Create Contact" from inside accounts

    Any help would be really appreciated

    thanks
    james

  2. #2
    chad.hutchins is offline Sugar Community Member
    Join Date
    May 2007
    Location
    Texas
    Posts
    141

    Default Re: How to turn a text field into a drop down

    if you want to change a custom field from one type to another, you will need to find the record for the field in the fields_meta_data table. You can search by field name to find the right field record. You will change the type from 'text' to 'enum'.

  3. #3
    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: How to turn a text field into a drop down

    Hi, james

    You can create an extended vardefs for the module.
    Supposing you are talking about the Contacts module in the SugarCRM CE 5.0.0x version.

    1. Create the file custom/Extension/modules/Contacts/Ext/Vardefs/vardefs.ext.php
    2. Create an array which modify the type of the field and defines the option

    PHP Code:
    $dictionary['Contact']['fields']['department']['type'] = 'enum';
    $dictionary['Contact']['fields']['department']['options'] = 'department_dom'
    After that you have to Rebuild Extensions

    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.

  4. #4
    chad.hutchins is offline Sugar Community Member
    Join Date
    May 2007
    Location
    Texas
    Posts
    141

    Default Re: How to turn a text field into a drop down

    Thanks andopes!

    Your solution is much better!

    I am curious, Sugar Hero, do you know if using my method would have caused other things in my system to break? I have used it on several custom fields that I have wanted to edit.

    Thanks

  5. #5
    richarddixonfl is offline Sugar Community Member
    Join Date
    Mar 2008
    Posts
    10

    Default Re: How to turn a text field into a drop down

    Quick question, I have a custom field named contract_purchaser_c in Leads, It was originally created as a Text box and has values in it. We have created a dropdown with the purchasers in it called dom_contract_purchasers and I have gone into LeadVarDefs.php within cache (since there is no mention of the field in vardefs.php under /modules/leads/) and have removed / readded the field in studio and deployed the views. I am now seeing a dropdown instead of a textfield, and see the appropriate values in the dropdown. the problem lies in that it is not showing the value that is set for that field in the database. If I select the correct value in edit view and save, it will then show up. It seems like the dropdown works but is not showing what is in the database until you resave it with the correct value. Is there a specific repair function that i should perform to make whats in the db show up in the field? (Also went into the fields_meta_data table in SQL and adjusted it accordingly just like any other enum field)

    Here is the section in leadvardefs.php that refers to the field:

    'contract_purchaser_c' =>
    array (
    'required' => 0,
    'source' => 'custom_fields',
    'name' => 'contract_purchaser_c',
    'vname' => 'LBL_CONTRACT_PURCHASER',
    'type' => 'enum',
    'massupdate' => 0,
    'default' => '-blank-',
    'comments' => '',
    'help' => '',
    'importable' => 'true',
    'duplicate_merge' => 'enabled',
    'duplicate_merge_dom_value' => '1',
    'audited' => 1,
    'reportable' => 1,
    'len' => 100,
    'options' => 'dom_contract_purchasers',
    'studio' => 'visible',
    'id' => 'Leadscontract_purchaser_c',
    'custom_module' => 'Leads',
    ),


    ANY Ideas?

  6. #6
    WEB11 is offline Senior Member
    Join Date
    Mar 2009
    Location
    Washington, DC
    Posts
    30

    Default Re: How to turn a text field into a drop down

    I used the code mentioned above to change the Subject field in the Cases module to a drop down list. This is what added under custom/Extension/modules/Cases/Ext/Vardefs/vardefs.ext.php

    Code:
    <?php 
    
    $dictionary['Case']['fields']['name']['type'] = 'enum';
    $dictionary['Case']['fields']['name']['options'] = 'a_problem_cat_list';
     
    ?>
    Thanks for the help André
    Last edited by WEB11; 2009-03-31 at 02:44 PM.

  7. #7
    dskanth is offline Senior Member
    Join Date
    Mar 2009
    Posts
    97

    Default Re: How to turn a text field into a drop down

    Hello, iam new to Sugar and facing a problem with the implementation of dynamic drop down.
    My requirement is that: i have a drop down box, under Accounts.
    And i need to populate this dropdown with the fields from a module called Clinics.
    Please advice. Your help is much appreciated.


  8. #8
    letrium is offline Sugar Community Member
    Join Date
    Dec 2008
    Posts
    614

  9. #9
    prasannagowri is offline Senior Member
    Join Date
    Apr 2009
    Posts
    52

    Default Re: How to turn a text field into a drop down

    hello i am new to sugar and i have a doubt regarding the Shortcuts.
    How to remove the Shortcuts panel in the top left side from a module ?
    Please suggest a solution. Help is much appreciated

  10. #10
    letrium is offline Sugar Community Member
    Join Date
    Dec 2008
    Posts
    614

    Smile Re: How to turn a text field into a drop down

    Quote Originally Posted by prasannagowri View Post
    hello i am new to sugar and i have a doubt regarding the Shortcuts.
    How to remove the Shortcuts panel in the top left side from a module ?
    Please suggest a solution. Help is much appreciated
    Please create your own thread.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Manually drop scheme (5.0 upgrade) ?
    By niallhannon in forum Installation and Upgrade Help
    Replies: 1
    Last Post: 2008-01-07, 05:41 PM
  2. Replies: 2
    Last Post: 2007-07-08, 11:26 PM
  3. add the contents of 4 drop down list in one field
    By Spy123 in forum Developer Help
    Replies: 0
    Last Post: 2007-01-24, 11:06 AM
  4. text area and drop down question
    By westn11 in forum Developer Help
    Replies: 1
    Last Post: 2005-06-23, 11:11 AM

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
  •