[TYPO3-dev] Bug in t3lib_loaddbgroup.php when using defVals while creating new records

JoH info at cybercraft.de
Thu Aug 10 01:28:29 CEST 2006


Hi folks.

Today I ran into some problems while transferring defVals to a TCE_form
containing group fields with MM relations.
In the link the defVal had been created correctly and it was transferred to
alt_doc.php (tested this with a debug of GPvars) but it never appeared in
the corresponding selectbox of the form.

Digging a bit deeper into the code I found out that it is a bug in
t3lib_loaddbgroup.php
In line 126 there's a check if the field is MM or not.

if($MMtable) {
  $this->readMM($MMtable,$MMuid);
} else {
  $this->readList($itemlist);
}
As you can see for this check only $MMtable is used.
If you create a new record the value for $MMuid always is empty since there
is no existing MM relation yet. So $this->readMM returns an empty value.

Changing the lines to

if($MMtable && $MMuid) {
  $this->readMM($MMtable,$MMuid);
} else {
  $this->readList($itemlist);
}

did the trick, because the empty $MMuid will trigger $this->readList instead
that will transfer the defVal (which is available in $itemlist) to the
field.

Could anyone check if this change will cause some unwanted behaviour?
IMHO it should not since $this->readMM would return a result anyway only if
$MMuid is not empty. (Which is only the case when editing a record but not
when creating a new one).

TIA

Joey

-- 
Wenn man keine Ahnung hat: Einfach mal Fresse halten!
(If you have no clues: simply shut your knob sometimes!)
Dieter Nuhr, German comedian
openBC: http://www.cybercraft.de
T3 cookbook: http://www.typo3experts.com






More information about the TYPO3-dev mailing list