我为 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 不是对象?
我该如何解决?我究竟做错了什么?这就是我设置相关字段所要做的一切,对吗?