Fields in modules are controlled by the vtiger_field table - the field must exist in the appropriate database table, and there must be a record in vtiger_field that describes the field.
vtiger_field looks like (V5.2):
Field | Type | Null | Key | Default |
---|---|---|---|---|
tabid | int(19) | NO | MUL | |
fieldid | int(19) | NO | PRI | NULL |
columnname | varchar(30) | NO | ||
tablename | varchar(50) | NO | ||
generatedtype | int(19) | NO | 0 | |
uitype | varchar(30) | NO | ||
fieldname | varchar(50) | NO | MUL | |
fieldlabel | varchar(50) | NO | ||
readonly | int(1) | NO | ||
presence | int(19) | NO | 1 | |
selected | int(1) | NO | ||
maximumlength | int(19) | YES | NULL | |
sequence | int(19) | YES | NULL | |
block | int(19) | YES | MUL | NULL |
displaytype | int(19) | YES | MUL | NULL |
typeofdata | varchar(100) | YES | NULL | |
quickcreate | int(10) | NO | 1 | |
quickcreatesequence | int(19) | YES | NULL | |
info_type | varchar(20) | YES | NULL | |
masseditable | int(10) | NO | 1 | |
helpinfo | text | YES | NULL |
Allowed field values are:
Field | Description | Allowed Values |
---|---|---|
tabid | ID number of the module (from vtiger_tab) | INT, tabid types |
fieldid | ID of field; generated by getUniqueID("vtiger_field"). Normally obtained at installation. | INT |
columnname | Name of the column in its table | any |
tablename | Name of the table that stores field | any table |
generatedtype | Specifies type of field in module whether 1='Exisiting' or 2='User Defined' | 1,2 |
uitype | Handles what widget displays field | Ui types |
fieldname | The vTiger name of the field | ?? |
fieldlabel | The label name of the field | vTiger will look for fieldlabel as a key in the the $mod_strings array stored at modules/ModuleName/language/<language prefix>.lang.php |
readonly | 0=true(ro) 1=false(rw) | BOOLEAN |
presence | Describes the nature of the field. 0=A system field (should always be present), 1=Field should be hidden and not displayed, 2=A normal-use field. | 0, 1 or 2 |
selected | ?? | ?? |
maximumlength | ?? | ?? |
sequence | The display order of your field in your block. | Number (1,2,3...) |
block | Block id (from Vtiger blocks) where the field will appear | INT |
displaytype | Indicates if field will be displayed on Create/Edit & Detail View. 1=displayed on all views, 2=displayed only in detail view (but not in edit), 3=field will not come separately, it will come along with other field, 4= only in the createview. it will not come other views(detailview & editview) | 1,2,3,4 |
typeofdata | X~Y, where X is the type of data V for varchar, N for numbers etc and Y stands for (O)ptional or (M)andatory | INV...~OM |
quickcreate | if field appears or not on quickcreate field | 0/1 |
quickcreatesequence | sequence of field in quick create screen | number |
info_type | 'BAS' field is displayed in Basic Information, 'ADV' field is displayed in More information | BAS or ADV |
masseditable | If field is shown and can be changed via the Mass edit dialogue | 0/1 |
helpinfo | Tooltip text for the field | text |
To insert this record into vtiger_field, you have to write an insert query for each field of the form:
Syntax: $this->db->query("insert into vtiger_field values ( <tabid>, $this->db->getUniqueID("vtiger_field"), <columnname>, <tablename>, <generatedtype>, <uitype>, <fieldname>, <fieldlabel>, <readonly>, <presence>, <selected>, <maximumlength>, <sequence>, <block>, <displaytype>, <typeofdata>, <quickcreate>, <quickcreatesequence>, <info_type> )");
For example take some field XYZ, for block 51, tab 20 the code is:
$this->db->query("insert into vtiger_field values(20, ".$this->db->getUniqueID("vtiger_field").", 'xyz', 'vtiger_quotes', 1, '2', 'xyz', 'XYZ', 1, 0, 0, 100, 1, 51, 1, 'V~M', 1, null, 'BAS' )");
or if you just want to inset this SQL straight in to your database, it would look something like this.
insert into vtiger_field values(20, '', 'xyz', 'vtiger_quotes', 1, '2', 'xyz', 'XYZ', 1, 0, 0, 100, 1, 51, 1, 'V~M', 1, null, 'BAS' );
This must be done once during the installation of the corresponding module. If the module is to be bundled with a new installation you can add the inserts into the 'modules/Users/DefaultDataPopulator.php' file under //Blockn (where n is the appropriate block number) and they will automatically be executed during step 5 of the installation process.