如何将相关字段设置为下拉列表 - SuiteCRM 版本 7.10.4 Sugar 版本 6.5.25(内部版本 344)

How to make relate field as Dropdown - SuiteCRM Version 7.10.4 Sugar Version 6.5.25 (Build 344)

我正在尝试通过从相关模块中获取值来制作下拉菜单,我尝试了以下操作,在路径中我添加了如下所述的代码。

Custom/Extension/Modules/mymodule/Ext/Vardefs/vardefs.php

$dictionary['mymodule']['fields']['custom_field'] = array(
'name' => 'custom_field',
'dbType' => 'non-db',
'source' => 'non-db',
'type' => 'relate',
'vname' => 'LBL_CUSTOM_TYPE',
'link' => 'accounts',
'module' => 'Accounts',
'rname' => 'account_type',
'studio' => 'visible',
);

但无法正常工作,我缺少任何东西。提前致谢。

它对我有用,添加 myfield.php 文件 路径:

\custom\Extension\modules\yourModule\Ext\Vardefs\myfield.php

代码:

<?php 

$dictionary["myModule"]["fields"]["myfield"] = array (
    'required' => true,
    'name' => 'myfield',
    'vname' => 'Select',
    'type' => 'enum',
    'required' => false,
    'massupdate' => 0,
    'comments' => '',
    'help' => '',
    'importable' => 'true',
    'duplicate_merge' => 'disabled',
    'duplicate_merge_dom_value' => '0',
    'audited' => false,
    'reportable' => true,
    'len' => 70,
    'size' => '20',
    'function' => 'getList',
);

?>

在 vardef 中我调用了一个函数 'getlist'

并在路径 getlist.php 中创建:

\custom\Extension\application\Ext\Utils\getlist.php

代码:

 <?php 
function getlistvalues(){
    static $listvalues = null;
    if(!$listvalues){
        global $db;
        $query = "SELECT id,name  FROM lm_leave_admin order by name asc ";
        $result = $db->query($query, false);
        $listvalues = array();
        $listvalues[''] = '';
        while (($row = $db->fetchByAssoc($result)) != null) {
            $listvalues[$row['id']] = $row['name'];
        }
    }
    return $listvalues;
} 
?>

最后进行快速修复和重建以查看更改。
**

Reference: https://community.sugarcrm.com/thread/21298

**