Module Field¶
Class Vtiger_Field provides API to work with a Module field, which are the basic elements that store and display the module record data.
The example given below describes the way of creating new field for the module created earlier:
include_once('vtlib/Vtiger/Module.php');
$fieldInstance = new Vtiger_Field();
$fieldInstance->name = 'PayslipName';
$fieldInstance->table = 'vtiger_payslip';
$fieldInstance->column = 'payslipname';
$fieldInstance->columntype = 'VARCHAR(100)';
$fieldInstance->uitype = 2;
$fieldInstance->typeofdata = 'V~M';
$blockInstance->addField($fieldInstance);
Note
The fieldInstance name is a mandatory value to be set before saving / adding to block. Other values (if not set) are defaulted as explained below
$fieldInstance->table |
Module’s basetable |
$fieldInstance->column |
$fieldInstance->name in lowercase [The table will be altered by adding the column if not present] |
$fieldInstance->columntype |
VARCHAR(255) |
$fieldInstance->uitype |
1 |
$fieldInstance->typeofdata |
V~O |
$fieldInstance->label |
$fieldInstance->name [Mapping entry should be present in module language file as well] |
Optional Settings
$fieldInstance->presence |
0 – Always Active (Cannot be modified using Layout Editor in 5.1.0) 1 – Mark it In Active (5.1.0 onwards) 2 – Active Property can be modified using Layout Editor (5.1.0 onwards) |
$fieldInstance->quickcreate |
0 – Enable field in Quick Create Form 1 – Disable field on Quick Create Form |
$fieldInstance->masseditable |
0 – Permanently Disallow field for mass editing (5.1.0 onwards) 1 – Allow field for mass editing (5.1.0 onwards) 2 – Disallow field for mass editing (but can be made available using Layout Editor 5.1.0 onwards) |
Entity Identifier¶
One of the mandatory field should be set as entity identifier of module once it is created. This field will be used for showing the details in ‘Last Viewed Entries’ etc…
$moduleInstance->setEntityIdentifier($fieldInstance);
Set Picklist Values¶
If the field is of Picklist type (uitype 15, 16, 33, 55, 111) then you can configure the initial values using the following API:
$fieldInstance->setPicklistValues( Array ('Value1', 'Value2') );
Set MassEdit property¶
You can make the field available for mass editing use the following ways described below: When creating the field you can set the property:
include_once('vtlib/Vtiger/Module.php');
$fieldInstance = new Vtiger_Field();
$fieldInstance->name = 'TestField';
...
...
$blockInstance->addField($fieldInstance);
If you have an existing field its property can be updated using the API:
$fieldInstance->setMassEditable(value);
The value set for masseditable property has the following meaning:
Value |
Description |
---|---|
0 |
Not available for mass edit and this property cannot be controlled by user. |
1 |
Available for mass edit |
2 |
Not available for mass edit but the property can be controlled by user (via Layout Manager etc) |