我试图通过从关联模块中获取值来创建一个下拉列表,我尝试了以下内容,在路径中我添加了如下所述的代码。
定制/扩展/模块/ MyModule的/外部/ 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',
);
但没有工作,我缺少的任何东西。提前谢谢。
答案 0 :(得分:1)
它对我有用,添加 myfield.php 文件 路径:
\定制\扩展\模块\ yourModule \分机\ 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 :
\定制\扩展\应用\分机\的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;
}
?>
最后进行快速修复和重建以查看更改 **
**