SugarCRM: Dynamically create dropdown values
<?php
//load needed libraries
require_once('modules/ModuleBuilder/MB/ModuleBuilder.php');
require_once('modules/ModuleBuilder/parsers/parser.dropdown.php');
$parser = new ParserDropDown();
$params = array();
$_REQUEST['view_package'] = 'studio'; //need this in parser.dropdown.php
$params['view_package'] = 'studio';
$params['dropdown_name'] = 'test_dropdown_list'; //replace with the dropdown name
$params['dropdown_lang'] = 'en_us';
//create your list...substitute with db query as needed
$drop_list[] = array('-blank-','');
$drop_list[] = array('First','This is the First Text');
$drop_list[] = array('Second','This is the Second Text');
$drop_list[] = array('Third','This is the Third Text');
$json = getJSONobj();
$params['list_value'] = $json->encode( $drop_list );
$parser->saveDropDown($params);
?>
Related articles
- How can I have one dropdown hide/show depending on the selection of another dropdown? (stackoverflow.com)
- single validation script for select dropdown (stackoverflow.com)
- populate a select dropdown on the basis of other other select dropdown (stackoverflow.com)
- SugarCRM: listview link for relate field (phpbugs.wordpress.com)
Advertisement
Posted on January 27, 2012, in SugarCRM and tagged PHP, SugarCRM, Drop-down list. Bookmark the permalink. Leave a Comment.


Leave a Comment
Comments (0)