From 3d3b794a59ab53786ae98c2a71df31a0ae5ce080 Mon Sep 17 00:00:00 2001
From: Stefan Froemken <froemken@gmail.com>
Date: Wed, 27 Mar 2013 08:47:52 +0100
Subject: [PATCH] [BUGFIX] IRRE children show no field values with
 useCombination

The IRRE option useCombination enables to use bi-directional
relations with IRRE items. This enables you to re-use IRRE
items multiple times (similar as FAL is working with IRRE).

To prevent the same child record from being used multiple
times, items already used are removed from the select box.
The code removing the item was written to remove an item
from a select box, but (accidentially) also targets a hidden
item which causes the JavaScript to break so that the field
values of the child objects are not filled on expanding.

By adding an additional check, this can be prevented.
For steps to reproduce refer to #46477.

Resolves: #46477
Releases: 6.2
Change-Id: Ie7fd89f6ef887b5d45c734dea8ec6ad9ac2a8d2c
Reviewed-on: https://review.typo3.org/19337
Reviewed-by: Fabien Udriot
Tested-by: Fabien Udriot
Reviewed-by: Zbigniew Jacko
Tested-by: Zbigniew Jacko
Reviewed-by: Xavier Perseguers
Tested-by: Xavier Perseguers
---
 .../Resources/Public/JavaScript/jsfunc.inline.js       | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/jsfunc.inline.js b/typo3/sysext/backend/Resources/Public/JavaScript/jsfunc.inline.js
index 3f768ed4549e..7d1cda2587e7 100644
--- a/typo3/sysext/backend/Resources/Public/JavaScript/jsfunc.inline.js
+++ b/typo3/sysext/backend/Resources/Public/JavaScript/jsfunc.inline.js
@@ -388,10 +388,12 @@ var inline = {
 				var recordObj = document.getElementsByName(this.prependFormFieldNames+'['+unique.table+']['+recordUid+']['+unique.field+']');
 				var values = $H(unique.used).values();
 				if (recordObj.length) {
-					var selectedValue = recordObj[0].options[recordObj[0].selectedIndex].value;
-					for (var i=0; i<values.length; i++) {
-						if (values[i] != selectedValue) {
-							this.removeSelectOption(recordObj[0], values[i]);
+					if (recordObj[0].hasOwnProperty('options')) {
+						var selectedValue = recordObj[0].options[recordObj[0].selectedIndex].value;
+						for (var i=0; i<values.length; i++) {
+							if (values[i] != selectedValue) {
+								this.removeSelectOption(recordObj[0], values[i]);
+							}
 						}
 					}
 				}
-- 
GitLab