Let the platform do the work

DropdownStyle

Overview

DropdownStyle implements the mechanics of assigning colors to dropdown fields. Currently, it is used in Charts, but it can also be applied anywhere dropdowns are used with customization. For example, in the Opportunities record view, this functionality could be customized in code to set a specific color for the sales_stage field based on its value.

Properties

The following DropdownStyle properties are available. For more information, please refer to the Extension Property documentation.

Property Value
Extension Scope Application
Sugar Variable $app_dropdowns_style
Extension Directory

./custom/Extension/application/Ext/DropdownsStyle/

DropdownStyle File

./custom/Extension/application/Ext/DropdownsStyle/<dropdown_name>_style.php

Implementation

The following sections illustrate the various ways to implement a customization to a Sugar instance.

Note: DropdownStyle colors are not be available for those dropdown fields that dynamically generate their options without taking them from $app_list_strings.

File System

When working directly with the filesystem, you can create a file in ./custom/Extension/application/Ext/DropdownsStyle/<dropdown_name>_style.php to write/override the dropdown style color scheme in the system. The following example will override the colors for the account_type_dom dropdown/enum in studio:

./custom/Extension/application/Ext/DropdownsStyle/acocunt_type_dom_style.php:

  <?php
$app_dropdowns_style['account_type_dom_style']=array (
  '' => 
  array (
    'backgroundColor' => '#517bf8',
  ),
  'Analyst' => 
  array (
    'backgroundColor' => '#36b0ff',
  ),
  'Competitor' => 
  array (
    'backgroundColor' => '#00e0e0',
  ),
  'Customer' => 
  array (
    'backgroundColor' => '#00ba83',
  ),
  'Integrator' => 
  array (
    'backgroundColor' => '#6cdf46',
  ),
  'Investor' => 
  array (
    'backgroundColor' => '#ffd132',
  ),
  'Partner' => 
  array (
    'backgroundColor' => '#ff9445',
  ),
  'Press' => 
  array (
    'backgroundColor' => '#fa374f',
  ),
  'Prospect' => 
  array (
    'backgroundColor' => '#f476b1',
  ),
  'Reseller' => 
  array (
    'backgroundColor' => '#cd74f2',
  ),
  'Other' => 
  array (
    'backgroundColor' => '#8f5ff5',
  ),
);

Next, navigate to Admin > Repair > Quick Repair and Rebuild. The system will then rebuild the extensions, clear dropdown caches and make available your custom color scheme.

Module Loadable Package

When building a module loadable package, you can use the $installdefs['copy'] index to install the extension file.

Installdef Properties

Name Type Description
from String The base path of the file
to_module String The key for the module where the file will be installed

The example below demonstrates the proper install definition that should be used in the ./manifest.php file in order to add a custom Dropdown color scheme to the system. When using this approach, you still need to use the $installdefs['copy'] index for DropdownStyle directory. Sugar will automatically clear dropdown cache, as well as Rebuild Extensions to reflect the new color scheme in the system.

 

./manifest.php

    <?php

$manifest = array(
    ...
);

$installdefs = array(
    'id' => 'dropdownstyle_example',
    'copy' => array(
        array(
            'from' => '<basepath>/Files/custom/Extension/application/Ext/DropdownsStyle/<dropdown_name>_style.php',
            'to' => 'custom/Extension/application/Ext/DropdownsStyle/<dropdown_name>_style.php',
        )
    )
);

For more information on the $installdefs['copy'] index and module-loadable packages, please refer to the Introduction to the Manifest page.

Topics