Adding custom dropdown(values dynamically from db) in the lead form in vTiger

1.1k views Asked by At

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 ?

1

There are 1 answers

6
Gautam D On

You can add drop-down field by using bellow code and follow the steps to achieve your result:

  1. Add bellow code in one PHP file (e.g add_to_lead.php).
  2. Put that file into your project directory.
  3. 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.