[Vtigercrm-developers] RESOLVED -- How to fire the $field_model->getDBInsertValue($value) method for a custom module field with custom uitype?

Holbok István holbok at gmail.com
Tue Aug 5 20:21:14 GMT 2014


Dear vtiger Team, and vtiger Community,

I have just found the solution:
There are 2 files responsible for the below mentioned issue:

.../modules/Vtiger/actions/Save.php
.../modules/Vtiger/actions/SaveAjax.php

and both of them contain a method: 
*getRecordModelFromRequest(Vtiger_Request $request) *and these methods 
(with too same names) are responsible for the getting record data and 
prepare data before save to the database.
Rewriting and extending the classes to the CustomModule and inserting a 
small snippet to the proper place
             if($fieldDataType == 'multipicklist'){
                 $fieldValue = $fieldModel->getDBInsertValue($fieldValue);
             }
the issue was handled.

So, I kindly ask you to review it and modify if it is necessary the core 
files to make able to handle fields by relating uitype records.

Regards:
Istvan

-------------------------------------------------------------------
Dear vtiger Team, and vtiger Community,

I am involved a vtiger 6.1 custom module development and now I've got 
stuck in this case:

I created a custom multipicklist field for this custom module. This 
multipicklist field is stored in the SQL db in the form of "1 |##| 2 
|##| 3" (similar to the vtiger standard multipicklist) where 1, 2 and 3 
the selected data indexes.
The $field_model->getDisplayValue($value) method - whit proper 
overwrites - works everywhere (listview, detailview, editview) and shows 
the field data as "Label1, Label2, Label3".

When editing (or creating a new) record of the custom module the 
consequence $field_model->getDBInsertValue($value) method is not called.

The custom multiselect field UI works well, because
- the label list is displayed well.
- if I choose only 1 item, e.g. Label2, the save method will save to the 
database 2 (2 = index of Label2).

- if I choose multiple selectable items, e.g. Label2 and Label3 the 
input content of the field will be consequently "2,3"
- if I choose multiple selectable items, e.g. Label2 and Label4 and 
Label5 the input content of the field will be consequently "2,4,5" - in 
this coma separated form.

I put debug tags to all related files and methods and I see in the 
debugger that the filed UI works, the multiselect works, but the 
$field_model->getDBInsertValue($value) method - where the "2,4,5" should 
be changed into "2 |##| 4 |##| 5" - *is not called*.

My question is how to fire this method depending the 
$field_model->uitype_model ?
*_
_**_The coma separated input of the field cause an other error also._*

And this is a vtiger 6.1 serious BUG.
This custom module record has 11 fields. And the update record method 
fired from the vtiger_module parent uses 10 fields to updete + the 
record_id = 11 input data together for the db-update method.

When a sole select in this filed - all work well.

When a multiple select in this custom field, the selected values e.g. 
"2,4,5" operate as independent integer values to insert or update sql. 
It means when the update method required 11 data unit, it will receive 
13 because the "2,4,5" will be interpreted as 3 separate values.
I think the missing db-quotes (in the basic methods) are responsible for 
this issue.

So, the other question is - how to handle it?

Kindest regards:
Istvan

-- 
üdvözlettel:

*Holbok István*

+3670-342-0900
*e-mail:* holbok at gmail.com
*SkyPe:* holboki

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20140805/61b40798/attachment-0001.html>


More information about the vtigercrm-developers mailing list