我需要在自定义模块的编辑视图中根据下拉字段的选定值显示/隐藏一些字段。SugarCRM CE版本为6.1.4。
我正在尝试:
$dictionary['<module name>']['fields']['<hidden field>']['dependency'] = 'equal($<trigger field>, "<trigger field value>")';
但这对我不起作用。欢迎任何建议。
提前感谢
我用javascript代码解决了这个问题。在模块中/模块/metadata/editviewdefs.php
'templateMeta' =>
array (
....
'includes'=>
array(
array('file'=>'modules/<module>/ShowHidePanel.js'),
),
'javascript' => '<script type="text/javascript" language="Javascript">showHidePanel();</script>',
...
array (
'name' => 'geometria',
'studio' => 'visible',
'label' => 'LBL_GEOMETRIA',
'displayParams' =>
array (
'javascript' => 'onchange=showHidePanel();',
),
),
并创建了文件模块/模块/ShowHidePanel.js
function showHidePanel() {
if(document.getElementById('geometria').value == 'pletina') {
document.getElementById('LBL_EDITVIEW_PANEL1').style.display = 'initial';
document.getElementById('LBL_EDITVIEW_PANEL2').style.display = 'none';
document.getElementById('LBL_EDITVIEW_PANEL3').style.display = 'none';
document.getElementById('LBL_EDITVIEW_PANEL4').style.display = 'none';
document.getElementById('LBL_EDITVIEW_PANEL5').style.display = 'none';
}else if(document.getElementById('geometria').value == 'redondo') {
document.getElementById('LBL_EDITVIEW_PANEL1').style.display = 'none';
document.getElementById('LBL_EDITVIEW_PANEL2').style.display = 'initial';
document.getElementById('LBL_EDITVIEW_PANEL3').style.display = 'none';
document.getElementById('LBL_EDITVIEW_PANEL4').style.display = 'none';
document.getElementById('LBL_EDITVIEW_PANEL5').style.display = 'none';
}
}
我不太确定CE版本是否支持使用SugarLogic-仅限Pro&据我所知,企业是这样做的。除此之外,您的原始代码看起来不错!
不过,对于未来的参考,这里有一个如何正确使用依赖关系的示例:http://support.sugarcrm.com/02_Documentation/04_Sugar_Developer/Sugar_Developer_Guide_6.7/03_Module_Framework/Sugar_Logic/02_Using_Sugar_Logic_Directly/Creating_a_custom_dependency_using_metadata/
可用操作列表:https://support.sugarcrm.com/02_Documentation/04_Sugar_Developer/Sugar_Developer_Guide_6.7/03_Module_Framework/Sugar_Logic/01_Dependencies/