我需要添加动作菜单,如详细视图中的图像所示。 我已经提到了以下主题来实现这一点,但它不适用于详细视图。
Adding new option in the action button of sugarCRM
require_once('include/MVC/View/views/view.detail.php');
class CustomAccountsViewDetail extends ViewDetail
{
function preDisplay()
{
parent::preDisplay();
$this->dv->actionsMenuExtraItems[] = $this->buildMyMenuItem();
}
function buildMyMenuItem()
{
global $app_strings;
return <<<EOHTML
<a class="menuItem" style="width: 150px;" href="#" onmouseover='hiliteItem(this,"yes");'
onmouseout='unhiliteItem(this);'
onclick="sugarListView.get_checks();
if(sugarListView.get_checks_count() < 1) {
alert('{$app_strings['LBL_LISTVIEW_NO_SELECTED']}');
return false;
}
document.MassUpdate.action.value='displaypassedids';
document.MassUpdate.submit();">Send records to a new view!</a>
EOHTML;
}
}
我在\ custom \ Modules \ Account \ views \ view.detail.php中添加了以下代码 感谢
答案 0 :(得分:1)
虽然以自己的方式定制SugarCRM很难,但我在下面的链接中得到了答案
http://www.technologyworkshops.net/php/add-custom-action-menu-in-sugarcrm-with-post-method-t133.html
这就是他们所说的
0 => 'EDIT',
1 => 'DUPLICATE',
2 => 'DELETE',
3 => 'FIND_DUPLICATES',
4 => array (
'customCode' => '<input
class="button"
title = "My Duplicate",
value="My Duplicate,
type="button"
name="duplicate_with_dets"
onclick="var _form = document.getElementById(\'formDetailView\');
var element = document.createElement(\'input\');
//Assign different attributes to the element.
element.setAttribute(\'type\', \'hidden\');
element.setAttribute(\'value\', \'{$fields.id.value}\');
element.setAttribute(\'name\', \'add_dets\');
_form.appendChild(element);
_form.return_module.value=\'Accounts\'; _form.return_action.value=\'DetailView\';
_form.isDuplicate.value=true; _form.action.value=\'EditView\'; _form.return_id.value=\'{$fields.id.value}\';
SUGAR.ajaxUI.submitForm(_form);"" />',
),
这也会添加一个自定义隐藏字段,该字段将在下一页发布。
欢呼:)
答案 1 :(得分:0)
有一个更优雅的解决方案。将detailviewdefs.php从modules / Accounts / metadata复制到custom / modules / Accounts / metadata
在文件的开头,你有一个名为'buttons'的数组,你可以添加一个带有任何html内容的customCode行,如下所示:
$viewdefs = array (
'Accounts' => array (
'DetailView' => array (
'templateMeta' => array (
'form' => array (
'buttons' =>
array (
0 => 'EDIT',
1 => 'DUPLICATE',
2 => 'DELETE',
3 =>
array (
'customCode' => '<input title="{$APP.LBL_DUP_MERGE}" accesskey="M" class="button" onclick="this.form.return_module.value=\'Opportunities\';this.form.return_action.value=\'DetailView\';this.form.return_id.value=\'{$fields.id.value}\'; this.form.action.value=\'Step1\'; this.form.module.value=\'MergeRecords\';" name="button" value="{$APP.LBL_DUP_MERGE}" type="submit">',
),
),
),
.
.
.
.