[BUGFIX] Get suggest wizard working with renderMode=checkbox
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / Form / FormEngine.php
index e2a3512..35b90b3 100644 (file)
@@ -563,6 +563,11 @@ class FormEngine {
         */
        protected $multiSelectFilterCount = 0;
 
+       /**
+        * @var \TYPO3\CMS\Backend\Form\Element\SuggestElement
+        */
+       protected $suggest;
+
        // Form templates, relative to typo3 directory
        /**
         * Constructor function, setting internal variables, loading the styles used.
@@ -2131,7 +2136,7 @@ TBE_EDITOR.customEvalFunctions[\'' . $evalData . '\'] = function(value) {
                        }
                }
                // Add an empty hidden field which will send a blank value if all items are unselected.
-               $item .= '<input type="hidden" name="' . htmlspecialchars($PA['itemFormElName']) . '" value="" />';
+               $item .= '<input type="hidden" class="select-checkbox" name="' . htmlspecialchars($PA['itemFormElName']) . '" value="" />';
                // Remaining checkboxes will get their set-all link:
                if (count($setAll)) {
                        $tableHead = '<thead>
@@ -5737,7 +5742,7 @@ TBE_EDITOR.customEvalFunctions[\'' . $evalData . '\'] = function(value) {
                                browserWin.focus();
                        }
                        function setFormValueFromBrowseWin(fName,value,label,title,exclusiveValues) {
-                               var formObj = setFormValue_getFObj(fName), fObj, isMultiple = false, isList = false, len;
+                               var formObj = setFormValue_getFObj(fName), fObj, isMultiple = false, isList = false, isCheckboxList = false, len;
                                if (formObj && value !== "--div--") {
                                                // Check if the form object has a "_list" element or not
                                                // The "_list" element exists for multiple selection select types
@@ -5746,6 +5751,7 @@ TBE_EDITOR.customEvalFunctions[\'' . $evalData . '\'] = function(value) {
                                                isMultiple =  fObj.multiple && fObj.getAttribute("size") != "1";
                                                isList = true;
                                        } else {
+                                               isCheckboxList = formObj[fName].className == "select-checkbox";
                                                fObj = formObj[fName];
                                        }
 
@@ -5809,6 +5815,20 @@ TBE_EDITOR.customEvalFunctions[\'' . $evalData . '\'] = function(value) {
                                                        setHiddenFromList(fObj,formObj[fName]);
                                                        ' . $this->TBE_EDITOR_fieldChanged_func . '
                                                }
+                                       } else if (isCheckboxList) {
+                                               var i=0;
+                                               while (formObj[fName + "[" + i + "]"]) {
+                                                       if (formObj[fName + "[" + i + "]"].value == value) {
+                                                               fObj = formObj[fName + "[" + i + "]"];
+                                                               break;
+                                                       }
+                                                       i++;
+                                               };
+
+                                               if (fObj && !fObj.checked) {
+                                                       fObj.click();
+                                                       ' . str_replace('_list', '', $this->TBE_EDITOR_fieldChanged_func) . '
+                                               }
                                        } else {
                                                        // The incoming value consists of the table name, an underscore and the uid
                                                        // For a single selection field we need only the uid, so we extract it
@@ -5998,6 +6018,7 @@ TBE_EDITOR.customEvalFunctions[\'' . $evalData . '\'] = function(value) {
                                        if (formObj[fName] &&
                                                (
                                                        (formObj[fName].type == "select-one") ||
+                                                       (formObj[fName].className == "select-checkbox") ||
                                                        (formObj[fName + "_list"] && formObj[fName + "_list"].type.match(/select-(one|multiple)/))
                                                )
                                        ) {