1

我为 vTiger 编写了这段代码,试图将 Quote 模块绑定到 Lead 模块的字段中:

$Vtiger_Utils_Log = true;
include_once('vtlib/Vtiger/Menu.php');
include_once('vtlib/Vtiger/Module.php');
//(module name without space)
$module = Vtiger_Module::getInstance('Leads');

// Create Block instance
$block1 = new Vtiger_Block();
$block1->label = 'Block Name';
$block1 = Vtiger_Block::getInstance('LBL_LEAD', $module);

$field0 = new Vtiger_Field();
$field0->name = 'Leads';
$field0->label = 'Leads';
$field0->uitype = 10;
$field0->typeofdata = 'V~O';
$field0->setRelatedModules(Array('Quotes'));
$block1->addField($field0);

这是我得到的回应:

Setting Leads relation with Quotes ... DONE
Fatal error: Call to a member function addField() on a non-object in /var/www/duvtiger/vtigerscript.php on line 23

为什么 $block1 不是对象?

我该如何解决?我究竟做错了什么?这就是我设置相关字段所要做的一切,对吗?

4

1 回答 1

5

尝试使用此代码添加新的相关字段。这肯定会对你有所帮助。您在添加字段之前设置了关系,这就是您得到的错误是“block1 不是对象”的原因。

$field0 = new Vtiger_Field();
$field0->name = 'quotes';
$field0->column = 'quotes';
$field0->table = $module->basetable; 
$field0->label = 'Test2';
$field0->uitype = 10;
$field0->typeofdata = 'V~O';
$block1->addField($field0);
$field0->setRelatedModules(Array('Quotes'));
于 2013-11-13T06:12:50.630 回答