[BUGFIX] IRRE records can't be expanded without an hidden field
authorOliver Hader <oliver@typo3.org>
Fri, 29 Jun 2012 16:41:41 +0000 (18:41 +0200)
committerOliver Hader <oliver.hader@typo3.org>
Wed, 4 Jul 2012 07:57:35 +0000 (09:57 +0200)
If no hidden field in TCA for IRRE child records, this will
lead to JavaScript errors on expanding the accordant child
record in the TCEforms view.

This regression has been introduced in issue #34303

Change-Id: If53182bf13a9d7d50479fe00561f3decbceb1fa2
Fixes: #37615
Related: #34303
Releases: 6.0, 4.7, 4.6, 4.5
Reviewed-on: http://review.typo3.org/11762
Reviewed-by: Oliver Hader
Tested-by: Oliver Hader
t3lib/class.t3lib_tceforms_inline.php
t3lib/jsfunc.inline.js

index 4466508..430642f 100644 (file)
@@ -400,8 +400,8 @@ class t3lib_TCEforms_inline {
                        } else {
                                        // Set additional field for processing for saving
                                $fields .= '<input type="hidden" name="' . $this->prependCmdFieldNames . $appendFormFieldNames . '[delete]" value="1" disabled="disabled" />';
-                               if (!$isExpanded) {
-                                       $checked = ($rec['hidden'] == 1) ? ' checked="checked"' : '';
+                               if (!$isExpanded && !empty($GLOBALS['TCA'][$foreign_table]['ctrl']['enablecolumns']['disabled'])) {
+                                       $checked = (!empty($rec['hidden']) ? ' checked="checked"' : '');
                                        $fields .= '<input type="checkbox" name="' . $this->prependFormFieldNames . $appendFormFieldNames . '[hidden]_0" value="1"' . $checked . ' />';
                                        $fields .= '<input type="input" name="' . $this->prependFormFieldNames . $appendFormFieldNames . '[hidden]" value="' . $rec['hidden'] . '" />';
                                }
@@ -2535,4 +2535,4 @@ class t3lib_TCEforms_inline {
        }
 }
 
-?>
\ No newline at end of file
+?>
index ff73672..72fd865 100644 (file)
@@ -425,6 +425,7 @@ var inline = {
                }
        },
        domAddRecordDetails: function(objectId, objectPrefix, expandSingle, htmlData) {
+               var hiddenValue, formObj, valueObj;
                var objectDiv = $(objectId + '_fields');
                if (!objectDiv || objectDiv.innerHTML.substr(0,16) != '<!--notloaded-->') {
                        return;
@@ -432,14 +433,28 @@ var inline = {
 
                var elName = this.parseObjectId('full', objectId, 2, 0, true);
 
-               var formObj = document.getElementsByName(elName+'[hidden]_0')[0];
-               var tempHiddenValue = formObj.checked;
-               formObj.remove();
-               document.getElementsByName(elName+'[hidden]')[0].remove();
+               formObj = document.getElementsByName(elName + '[hidden]_0');
+               valueObj = document.getElementsByName(elName + '[hidden]');
 
+                       // It might be the case that a child record
+                       // cannot be hidden at all (no hidden field)
+               if (formObj.length && valueObj.length) {
+                       hiddenValue = formObj[0].checked;
+                       formObj[0].remove();
+                       valueObj[0].remove();
+               }
+
+                       // Update DOM
                objectDiv.update(htmlData);
-               document.getElementsByName(elName+'[hidden]')[0].value = tempHiddenValue ? 1 : 0;
-               document.getElementsByName(elName+'[hidden]_0')[0].checked = tempHiddenValue;
+
+               formObj = document.getElementsByName(elName + '[hidden]_0');
+               valueObj = document.getElementsByName(elName + '[hidden]');
+
+                       // Set the hidden value again
+               if (formObj.length && valueObj.length) {
+                       valueObj[0].value = hiddenValue ? 1 : 0;
+                       formObj[0].checked = hiddenValue;
+               }
 
                        // remove loading-indicator
                if ($(objectId + '_icon')) {
@@ -757,22 +772,26 @@ var inline = {
        },
 
        enableDisableRecord: function(objectId) {
-               var elName = this.parseObjectId('full', objectId, 2, 0, true);
-               var currentUid = this.parseObjectId('none', objectId, 1);
-               var objectPrefix = this.parseObjectId('full', objectId, 0, 1);
-               var formObj = document.getElementsByName(elName+'[hidden]_0')[0];
-
-               formObj.click();
-
-               document.getElementsByName(elName+'[hidden]')[0].value = formObj.checked?1:0;
-               TBE_EDITOR.fieldChanged(objectPrefix,'1','hidden',elName+'[hidden]');
-
-               if($(objectId+'_disabled').hasClassName('t3-icon-edit-hide')) {
-                       $(objectId+'_disabled').removeClassName ('t3-icon-edit-hide');
-                       $(objectId+'_disabled').addClassName('t3-icon-edit-unhide');
-               } else {
-                       $(objectId+'_disabled').removeClassName ('t3-icon-edit-unhide');
-                       $(objectId+'_disabled').addClassName('t3-icon-edit-hide');
+               var elName = this.parseObjectId('full', objectId, 2, 0, true) + '[hidden]';
+               var formObj = document.getElementsByName(elName + '_0');
+               var valueObj = document.getElementsByName(elName);
+               var icon = $(objectId + '_disabled');
+
+                       // It might be the case that there's no hidden field
+               if (formObj.length && valueObj.length) {
+                       formObj[0].click();
+                       valueObj[0].value = formObj[0].checked ? 1 : 0;
+                       TBE_EDITOR.fieldChanged_fName(elName, elName);
+               }
+
+               if (icon) {
+                       if (icon.hasClassName('t3-icon-edit-hide')) {
+                               icon.removeClassName ('t3-icon-edit-hide');
+                               icon.addClassName('t3-icon-edit-unhide');
+                       } else {
+                               icon.removeClassName ('t3-icon-edit-unhide');
+                               icon.addClassName('t3-icon-edit-hide');
+                       }
                }
 
                return false;
@@ -1142,4 +1161,4 @@ Object.extend(Array.prototype, {
        }
 });
 
-/*]]>*/
\ No newline at end of file
+/*]]>*/