I've written this code for vTiger, trying to tie the Quote module into a field for the Lead module:
$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);
This is the response I'm getting:
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
Why is $block1 not an object?
How do I fix this? What am I doing wrong? This is all I have to do to setup the related field, correct?
$block1
object with the result of$block1 = Vtiger_Block::getInstance('LBL_LEAD', $module);
, better naming convention I reconprint_r($block1)
shows if you add it before addField() line?