[TYPO3-dev] TCA UserFunction - saving multiple values
Simon Justesen
simon at simm.removedk
Fri May 16 20:36:23 CEST 2008
Martin Kutschker wrote:
> Simon Justesen schrieb:
>> Simon Justesen skrev:
>>> Steffen Kamper skrev:
>>>> "Simon Justesen" <simon at FJERNDETTEsimm.dk> schrieb im Newsbeitrag
>>>> news:mailman.1.1210713472.616.typo3-dev at lists.netfielders.de...
>>>>> Hey fellow TYPO3 users
>>>>>
>>>>> I've made a custom $TCA userfunction. I can easily save single
>>>>> values to a table field, but how can I add some preprocessing
>>>>> before writing the value to the database?
>>>>>
>>>>> I have a productfield and a price-field which I have to save to the
>>>>> same database field in the this way: product;price so that I can
>>>>> explode() it later.
>>>>>
>>>>> Thanks
>>>>> Simon
>>>>
>>>> Hi,
>>>>
>>>> use one of the hooks in tcemain, eg processDatamapClass or
>>>> processDatamap_preProcessFieldArray to do what ever you want.
>>>>
>>>> vg Steffen
>>>>
>>>
>>> Hey Steffen
>>>
>>> Thank you very much - I'll check it out
>>>
>>> Best regards
>>> Simon
>>
>> Hi
>>
>> I've got an additional question: How do I save the processed data back
>> to the database?
>>
>> Tried with the usual $GLOBALS['TYPO3_DB']->exec_UPDATEquery but the
>> $incomingFieldArray contains this additional field
>>
>> _TRANSFORM_productdescription='RTE',
>>
>> causing the update-query to fail because no such field exist in the
>> database.
>>
>> I used the below-mentioned to test the hook
>>
>> function processDatamap_preProcessFieldArray($incomingFieldArray,
>> $table, $id, &$pObj)
>> {
>> t3lib_div::debug($incomingFieldArray);
>> $incomingFieldArray['tools']['toolname'] = 1;
>>
>> $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table,'uid='.$id.'',$incomingFieldArray);
>>
>> }
>
> Why don't you modify the $incomingFieldArray?
>
> function processDatamap_preProcessFieldArray(
> &$incomingFieldArray, $table, $id, &$pObj) {
> if ($table == 'yourtable') {
> $incomingFieldArray['yourfield'] = 1;
> }
> }
>
> Masi
Thanks Masi - works like a charm!
More information about the TYPO3-dev
mailing list