Overview
Provides a technical overview of the various ways to manage lists.
Modifying Lists
There are 3 ways to modify lists within Sugar.
Studio
Lists can be managed in 2 ways within Studio. If you know the name of the list you would like to edit, you can navigate to the dropdown editor:
Admin > Studio > Dropdown Editor
Alternatively, you can also navigate to your module field using the list and edit it by going to:
Admin > Studio > *module* > Fields > *field*
Direct Modification
There are two ways to directly modify the language strings. The first way is to modify the custom language file.
./custom/include/language/<language key>.lang.php
If you are developing a customization to be distributed and want to be able to create new or override existing list values, you will need to work within the extension application directory. To do this you will create a file as follows:
./custom/Extension/application/Ext/Language/<language key>.<unique name>.php
The file will contain your override values. Please note that within this file you will set each label index individually. An example of this is:
<?php
$app_list_strings['LIST_NAME']['Key_Value'] = 'My Display Value';
Once the file is created with your adjustments, you will then navigate to Admin > Repair > Quick Rebuild & Repair. This will compile all of the Extension files from:
./custom/Extension/application/Ext/Language/
To:
./custom/application/Ext/Language/<language key>.lang.ext.php
Dropdown Helper
You can use the Dropdown Helper to manage the lists at a code level. The example below demonstrates how to add and update values for a specific dropdown list.
require_once('modules/Studio/DropDowns/DropDownHelper.php');
$dropdownHelper = new DropDownHelper();$parameters = array();
$parameters['dropdown_name'] = 'example_list';
$listValues = array(
'Key_Value_1' => 'Display Value 1',
'Key_Value_2' => 'Display Value 2',
'Key_Value_3' => 'Display Value 3');
$count = 0;foreach ($listValues as $key=>$value){
$parameters['slot_'. $count] = $count;
$parameters['key_'. $count] = $key;
$parameters['value_'. $count] = $value;
//set 'use_push' to true to update/add values while keeping old values
$parameters['use_push'] = true;
$count++;}$dropdownHelper->saveDropDown($parameters);