Bug #25347

TCA type "select", renderMode "tree", maxitems = 1 doesn't work

Added by Marco Huber about 9 years ago. Updated about 9 years ago.

Should have
Target version:
Start date:
Due date:
% Done:


TYPO3 Version:
PHP Version:
Is Regression:
Sprint Focus:


I want to use the new TCA tree, but when I configure 1 as maxitems I can't select a tree node.

This happens, because this.countSelectedNodes in t3lib\js\extjs\tree\tree.js is 1 even when I create a new record. And this.countSelectedNodes is 1 because $valueArray in t3lib\tceforms\class.t3lib_tceforms_tree.php in the function renderField always has at least one entry.

$valueArray is created by exploding $PA['itemFormElValue']. In fresh records $PA['itemFormElValue'] is 0 and not NULL (or not set) and has no other effects. But $valueArray has an entry and that's why count($valueArray) is 1 and then this.countSelectedNodes is also 1.

To fix this issue $PA['itemFormElValue'] should be only exploded when it's not 0. Like I worte, this is done in t3lib\tceforms\class.t3lib_tceforms_tree.php and fixed in the appended patch.

Fixing this issue causes a little follow up in t3lib\js\extjs\tree\tree.js. This is also fixed in the patch.

I hope the patch file's syntax is correct, this is my first git patch ;-)

(issue imported from #M17976)

fix_tcatree_maxitem1.patch View (1.74 KB) Administrator Admin, 2011-03-16 16:53

Related issues

Duplicated by TYPO3 Core - Bug #25820: maxitems is not working correctly in tcaTree Closed 2011-04-07

Associated revisions

Revision 9b3bf788 (diff)
Added by Helmut Hummel about 9 years ago

[CLEANUP] Replace spaces with tabs

By fixing #25347 spaces were used as indention instead of tabs.
Replace the spaces with tabs as a cleanup.

Change-Id: I7f0005e7a53339c59a393fc8254c9fdd9ba87f23
Reviewed-on: http://review.typo3.org/1508
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel

Revision 3019ca92 (diff)
Added by Marco Huber about 9 years ago

[BUGFIX] TCA tree with maxitems=1 doesn't work

  • Check if value of the parent field is neither empty nor 0,
    because t3lib_transferData returns 0 if the database field
    is empty and maxitems=1
  • Only check if the selected nodes reached the maxitems limit
    if a node is checked, not if one is unchecked.

Change-Id: I89efc539cf720a6798d244e0a499d6bebff32d9f
Resolves: #25347
Reviewed-on: http://review.typo3.org/1211
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
Reviewed-by: Marco Huber
Tested-by: Marco Huber
Reviewed-by: Andreas Wolf

Revision 06711c2c (diff)
Added by Helmut Hummel about 9 years ago

[CLEANUP] Fix TCA tree the same as in TYPO3_4-5

The TCA tree feature did not work when setting maxitems=1 in the TCA.

This bug has been fixed in master in 290529a75647fe2bf6847638763e50348631e906 and in
TYPO3_4-5 branch 3019ca92f55faf650ad5981a001e323a2e91eab6 but the solution is different.

Use the same solution as is TYPO3_4-5 because it is cleaner:

  • Check for empty() value instead of comparing with 0 in
  • Do not recalculate the number of checked items only if a new
    item is checked and the maximum item count is reached instead of always
    recalculating the item count in

Resolves: #25347
Releases: 4.6

Change-Id: I1b55960f9c26f57aa05d6a95a9980798c06e8316
Reviewed-on: http://review.typo3.org/1804
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel


#1 Updated by Marco Huber about 9 years ago

To reproduce this issue you can use this TCA (Thanks to Steffen: http://lists.typo3.org/pipermail/typo3-team-core/2010-November/044931.html):
$GLOBALS['TCA']['pages']['columns']['fe_group']['config']['renderMode'] = 'tree';
$GLOBALS['TCA']['pages']['columns']['fe_group']['config']['maxitems'] = 1;
$GLOBALS['TCA']['pages']['columns']['fe_group']['config']['treeConfig'] = array(
'parentField' => 'subgroup',
'appearance' => array(
'expandAll' => TRUE,
'showHeader' => TRUE,

#3 Updated by Anonymous about 9 years ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 100

#4 Updated by Helmut Hummel about 9 years ago

  • Status changed from Resolved to Under Review
  • Target version changed from 0 to 4.5.3

In master this was merged: https://review.typo3.org/1188
In 4-5 there is a nicer version of this panding: https://review.typo3.org/1211

I still prefer this in favour of what is suggested in #25820

#5 Updated by Marco Huber about 9 years ago

  • Status changed from Under Review to Resolved

#6 Updated by Oliver Hader about 9 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF