[TYPO3-dev] TCEmain hook for postprocessing data fails updating select fields

Thomas "Thasmo" Deinhamer thasmo at gmail.com
Wed Apr 21 14:20:16 CEST 2010


I finally found the solution!

When using the hook 'processDatamap_preProcessFieldArray()' - note 'PRE' 
- it is possible to provide plain data (like an array) to fields which 
can hold multiple relations, or have a relation to a MM table and TYPO3 
i.e. TCEmain will handle the given data and create all needed MM 
relations automatically.

When using 'processDatamap_postProcessFieldArray()' # note 'POST' - this 
is not working and TYPO3 i.e. TCEmain will throw an error. It seems this 
method/hook makes sense to set fields directly with no further 
processing - except the field/database checks performed by TCEmain 
afterwards.

Hopefully this will help someone in the future.

Regards,
Thomas

Am 20.04.2010 17:17, schrieb Thomas "Thasmo" Deinhamer:
> Ah, sorry - to clear this up:
>
> They way I do this for a news article is to use a new instance of the
> TCEmain class:
>
> $engine = t3lib_div::makeInstance('t3lib_TCEmain');
> $engine->stripslashes_values = 0;
> $engine->start($map, array());
> $engine->process_datamap();
>
> This way it cares about the MM relation etc. and does everything on it's
> own, without manually setting any relations at all.
>
> If I use the hook, and change/set the category field it seems, TCEmain
> won't process this further and wants to store the given, plain value.
>
> Is there any functionality or solution to avoid manually creating those
> MM relations, and telling TCEmain or TYPO3 to do so? In case of the
> hook, which just runs when 'updating' a record, I need to be sure to
> delete all existing MM relations, and then add new ones - which is imho
> a lot of code, which may be implemented already somewhere in TYPO3?
>
> Thanks a lot,
> Thomas
>
>
> Am 20.04.2010 17:01, schrieb JoH asenau:
>> Thomas "Thasmo" Deinhamer wrote:
>>> Hello folks!
>>>
>>> When trying to update/postprocess a select field with a TCEmain hook,
>>> I get the error:
>>> "102: These fields are not properly updated in database: (category_id)
>>> Probably value mismatch with fieldtype."
>>>
>>> This happens e.g. for the extension 'cal' when trying to set some
>>> categories for an event by hand:
>>> $fields['category_id'] = array(1,2);
>>>
>>> I even tried:
>>> $fields['category_id'] = '1,2';
>>
>> category_id is INT(11) so the message is correct.
>>
>>> When doing the same for a tt_news record, setting some categories the
>>> same way, everything works fine. (I guess TCEmain cares about the MM
>>> table and handles the creation of the desired MM records etc.)
>>
>> Of course it does, so you have to do it accordingly:
>> 1) Get the desired values
>> 2) create according entries in the MM table.
>> 3) Count the overall entries in the MM table
>> 4) Write this value back to category_id
>>
>> This is default behaviour for MM related fields in TYPO3.
>> The field itself contains just the current number of relations.
>>
>> HTH
>>
>> Joey
>>




More information about the TYPO3-dev mailing list