Issue Bug Closed

#16459Bug in t3lib_loaddbgroup.php when using defVals while creating new records

JoH 08/11/06, 11:21 updated 10/29/08, 19:00

Description

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).

Try to fill in a predefined defVal for a group field with MM relations via URL Parameter while calling a backendform.

(issue imported from #M4022)

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.