vriger 添加新的字段 需要操作 vtiger_field 表

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
tabidint(19)NOMUL 
fieldidint(19)NOPRINULL
columnnamevarchar(30)NO  
tablenamevarchar(50)NO  
generatedtypeint(19)NO 0
uitypevarchar(30)NO  
fieldnamevarchar(50)NOMUL 
fieldlabelvarchar(50)NO  
readonlyint(1)NO  
presenceint(19)NO 1
selectedint(1)NO  
maximumlengthint(19)YES NULL
sequenceint(19)YES NULL
blockint(19)YESMULNULL
displaytypeint(19)YESMULNULL
typeofdatavarchar(100)YES NULL
quickcreateint(10)NO 1
quickcreatesequenceint(19)YES NULL
info_typevarchar(20)YES NULL
masseditableint(10)NO 1
helpinfotextYES NULL


Allowed field values are:

 

Field Description Allowed Values
tabidID number of the module (from vtiger_tab)INT, tabid types
fieldidID of field; generated by getUniqueID("vtiger_field"). Normally obtained at installation.INT
columnnameName of the column in its tableany
tablenameName of the table that stores fieldany table
generatedtypeSpecifies type of field in module whether 1='Exisiting' or 2='User Defined'1,2
uitypeHandles what widget displays fieldUi types
fieldnameThe vTiger name of the field ??
fieldlabelThe label name of the fieldvTiger will look for fieldlabel as a key in the the $mod_strings array stored at modules/ModuleName/language/<language prefix>.lang.php
readonly0=true(ro) 1=false(rw)BOOLEAN
presenceDescribes 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 ?? ??
sequenceThe display order of your field in your block.Number (1,2,3...)
blockBlock id (from Vtiger blocks) where the field will appearINT
displaytypeIndicates 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
typeofdataX~Y, where X is the type of data V for varchar, N for numbers etc and Y stands for (O)ptional or (M)andatoryINV...~OM
quickcreateif field appears or not on quickcreate field0/1
quickcreatesequencesequence of field in quick create screennumber
info_type'BAS' field is displayed in Basic Information, 'ADV' field is displayed in More informationBAS or ADV
masseditableIf field is shown and can be changed via the Mass edit dialogue0/1
helpinfoTooltip text for the fieldtext


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.

转载于:https://my.oschina.net/wangwang110/blog/11160

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值