在 SugarCRM 中使用条件删除详细视图中的按钮 [英] Remove button in detailview with condition in SugarCRM
问题描述
我的代码:
$GLOBALS['listbutton'] = $this->dv->defs['templateMeta']['form']['buttons'];
if ($this->bean->status == 'Converted') {
unset($this->dv->defs['templateMeta']['form']['buttons'][0]);
}
parent::display();
$GLOBALS['log']->debug("INFOdation log Display");
$this->dv->defs['templateMeta']['form']['buttons'] = $GLOBALS['listbutton'];
但是当 status =='New' 时,编辑按钮仍然隐藏.你可以帮帮我吗.我只想在状态 == '已转换' 时隐藏编辑按钮,其他状态必须显示.
But when status =='New' , the edit button still hide. Could you help me. I only want edit button hide when status == 'Converted', other status it has to apperance.
推荐答案
您可以使用 Javascript 隐藏按钮.
You could hide the Button with Javascript.
在 detailviewdefs.php 中包含您的脚本
in the detailviewdefs.php include your script
'includes' =>
array (
0 =>
array (
'file' => 'custom/modules/Leads/button_hide.js',
),
),
类似于:
SUGAR.util.doWhen("typeof $ != 'undefined'", function(){
if($(#status).val() == "Converted")$('#delete_button').parent().hide();
});
(SUGAR.util.doWhen ist the SugarCrm onload if ajax is enabled)
(SUGAR.util.doWhen ist the SugarCrm onload if ajax ist enabled)
如果字段状态不在您的视图中,您需要在 detailviewdefs.php 中添加一个隐藏字段并使用智能代码设置值,例如:
if the Field status is not in your view you will need to add a hidden field in detailviewdefs.php and set the value with smarty code like:
<input type="hidden" id="status" value="{$fields.status.value}">
这篇关于在 SugarCRM 中使用条件删除详细视图中的按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!