Reputation: 5
I am new to vtiger crm and need a code to add the dropdown that has values from the database table in add lead page. Please provide a solution if somebody have ?
Upvotes: 0
Views: 1234
Reputation: 330
You can add drop-down field by using bellow code and follow the steps to achieve your result:
Run that file from browser (e.g www.yourVtigerhost.com/add_to_lead.php)
$Vtiger_Utils_Log = true;
include_once('vtlib/Vtiger/Menu.php');
include_once('vtlib/Vtiger/Module.php');
$module = new Vtiger_Module();
$module = $module->getInstance('Leads');
// Create new Block into Lead Module and your drop-down added into new block
$block1 = new Vtiger_Block();
$block1->label = 'LBL_LEAD_INFORMATION';
$block1 = $block1->getInstance($block1->label,$module);
$field0 = new Vtiger_Field();
$field0->name = 'your field name';
$field0->table = $module->basetable;
$field0->label = 'Your field Name to display';
$field0->column = 'field_name';
$field0->columntype = 'VARCHAR(100)';
$field0->uitype = 15;
$field0->setPicklistValues( Array ('Dropdown Value1','Dropdown Value2','Dropdown Value3'));
$field0->typeofdata = 'V~O';
$block1->addField($field0);
New Dropdown have values like Dropdown Value1,Dropdown Value2,Dropdown Value3
If you want to add more values into dropdown than you can add from Setting-> Studio->Picklist Editor.
Upvotes: 1