How to create custom field in module in vTigerCRM

Create custom field in module in vTigerCRM

Creating a custom field in a module in vTigerCRM (Open Source) is fairly straightforward using the built-in Module Manager or through code/database, depending on your approach.

Method 1:

Using the vTiger CRM UI (Recommended for Most Users)

  • Login to vTiger as Admin
  • Go to CRM Settings > Module Manager
  • Choose the module (e.g., Leads, Contacts, etc.) where you want to add a custom field
  • Click Layout Editor
  • Select the block where you want the field added (or create a new block)
  • Click Add Custom Field
  • Choose the field type (Text, Picklist, Currency, Date, etc.)
  • Set the field name, label, and any other options
  • Click Save

Method 2:

Programmatically via Code (For Developers)
If you’re developing a module or doing a migration/import, you can create a custom field via PHP.

This is how I would make to add a field.

name = ‘whatsapp’;
$fieldInstance->label = ‘LBL_WHATSAPP’;
$fieldInstance->table = ‘vtiger_contactdetails’;
$fieldInstance->column = ‘whatsapp’;
$fieldInstance->columntype = ‘varchar(11)’;
$fieldInstance->uitype = 1;
$fieldInstance->typeofdata = ‘V~O’;
$blockInstance->addField($fieldInstance);
$fieldInstance->setRelatedModules(array(‘Accounts’));
}
else{
echo “field already present”;
}
}
else{
echo “no block”;
}
}
else{
echo “no module”;
}

?>

Enjoy!