Project

General

Profile

Actions

Bug #16459

closed

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

Added by JoH over 18 years ago. Updated about 16 years ago.

Status:
Closed
Priority:
Should have
Assignee:
Category:
-
Target version:
-
Start date:
2006-08-11
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
4.0
PHP Version:
4.3
Tags:
Complexity:
Is Regression:
Sprint Focus:

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)


Files

0004022.patch (1.53 KB) 0004022.patch Administrator Admin, 2007-02-13 02:20

Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #16476: TCAdefaults.table.field doesn't work for MM-fieldsClosedOliver Hader2006-08-18

Actions
Actions #1

Updated by Marc Bastian Heinrichs about 18 years ago

Hi Joey,

your change fixes my bug report #16476 as well.
http://bugs.typo3.org/view.php?id=4060

MBH

Actions #2

Updated by Franz Holzinger about 18 years ago

Hello Joey, I think the behaviour should be changed in a different way. When you use a mm table for a select box, then the special field containg values separated by comma ',' should not be used any more. If you want to select entries from a selection group coming from a mm table then the mm table shall be filled or nothing should be shown at all.

Actions #3

Updated by Andreas Frthner almost 18 years ago

Hi all,

this patch works great. I don't really understand what you mean Franz, because the MM Table will be used if I save the record, it is just for preselecting via the defVals GET variable. This is definitely a bug in the core that can be fixed so easily. So please commit this for the upcoming version 4.1. It would be very sad, if i must patch the core with every update.

Please, please commit it ;-)

Actions #4

Updated by Andreas Frthner almost 18 years ago

Please have a look at it ;-) This bug needs just one minute to fix. I sadly have no write access to svn ;-)

Actions #5

Updated by Oliver Hader almost 18 years ago

The suggested patch is attached as separate patch file (0004022.patch). It solves the problem. The $MMuid is empty on creating a blank new "parent" record.
The defVals will be set using t3lib_transferdate, but this also uses t3lib_loadDBgroup. So IMO this solution is okay.

It is possible to set defaul values for MM relations like this on User TSconfig:
TCEdefaults.[table].[field] = [id]
TCEdefaults.[table].[field] = [tablename]_[id]
e.g.
TCEdefaults.[table].[field] = 123
TCEdefaults.[table].[field] = tx_myext_child_123

Actions #6

Updated by Oliver Hader almost 18 years ago

Oh sorry, I just realized this is the defVals bug and not the TCAdefault bug. I mixed it. But it should work the same however. ;-)

Actions #7

Updated by Steffen Kamper over 17 years ago

Hi Oliver,

i applied the patch and tried to set a default value vor MM-Field in cal:

TCEdefaults.tx_cal_event.monitor_cnt=1
TCEdefaults.tx_cal_event.monitor_cnt=fe_users_1

like you told, but it doesn't work. Do you have an advice ?

Actions

Also available in: Atom PDF