[BUGFIX] TCA tree with maxitems=1 doesn't work
authorMarco Huber <mail@marco-huber.de>
Thu, 17 Mar 2011 12:53:13 +0000 (13:53 +0100)
committerAndreas Wolf <andreas.wolf@ikt-werk.de>
Tue, 26 Apr 2011 13:13:50 +0000 (15:13 +0200)
* 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
t3lib/js/extjs/tree/tree.js
t3lib/tceforms/class.t3lib_tceforms_tree.php

index 6e45634..95ff4b2 100644 (file)
@@ -211,7 +211,7 @@ TYPO3.Components.Tree.TcaCheckChangeHandler = function(checkedNode, checked) {
                }
        }
 
-       if (this.countSelectedNodes >= this.tcaMaxItems) {
+       if (checked === true && this.countSelectedNodes >= this.tcaMaxItems) {
                checkedNode.attributes.checked = false;
                checkedNode.getUI().toggleCheck(false);
                this.resumeEvents();
index 3d00055..d1a0c4f 100644 (file)
@@ -65,8 +65,13 @@ class t3lib_TCEforms_Tree {
         * @return string The HTML code for the TCEform field
         */
        public function renderField($table, $field, $row, &$PA, $config, $possibleSelectboxItems, $noMatchLabel) {
-               $valueArray = explode(',', $PA['itemFormElValue']);
+               $valueArray = array();
                $selectedNodes = array();
+
+               if(!empty($PA['itemFormElValue'])) {
+                       $valueArray = explode(',', $PA['itemFormElValue']);
+               }
+
                if (count($valueArray)) {
                        foreach ($valueArray as $selectedValue) {
                                $temp = explode('|', $selectedValue);