From 97c25eda6cba88ee24604e2050d8ac52a628ce06 Mon Sep 17 00:00:00 2001
From: Benjamin Mack <benni@typo3.org>
Date: Tue, 29 Sep 2015 13:08:16 +0200
Subject: [PATCH] [BUGFIX] Allow edit popup wizard to select a record

Resolves: #70167
Releases: master
Change-Id: Idf41369b956bc868f861353bae11dbd506069dbd
Reviewed-on: http://review.typo3.org/43622
Reviewed-by: Robert van Kammen <rvkammen@hotmail.com>
Tested-by: Robert van Kammen <rvkammen@hotmail.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
---
 .../backend/Classes/Form/Element/AbstractFormElement.php    | 6 +++---
 .../Resources/Public/JavaScript/jsfunc.tbe_editor.js        | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/typo3/sysext/backend/Classes/Form/Element/AbstractFormElement.php b/typo3/sysext/backend/Classes/Form/Element/AbstractFormElement.php
index cb983ecfac8d..94935d01fec6 100644
--- a/typo3/sysext/backend/Classes/Form/Element/AbstractFormElement.php
+++ b/typo3/sysext/backend/Classes/Form/Element/AbstractFormElement.php
@@ -295,7 +295,7 @@ abstract class AbstractFormElement extends AbstractNode {
 					if (isset($wizardConfiguration['popup_onlyOpenIfSelected']) && $wizardConfiguration['popup_onlyOpenIfSelected']) {
 						$notSelectedText = $languageService->sL('LLL:EXT:lang/locallang_core.xlf:mess.noSelItemForEdit');
 						$onlyIfSelectedJS =
-							'if (!TBE_EDITOR.curSelected(' . GeneralUtility::quoteJSvalue($itemName . $listFlag) . ')){' .
+							'if (!TBE_EDITOR.curSelected(' . GeneralUtility::quoteJSvalue($itemName) . ')){' .
 								'alert(' . GeneralUtility::quoteJSvalue($notSelectedText) . ');' .
 								'return false;' .
 							'}';
@@ -306,7 +306,7 @@ abstract class AbstractFormElement extends AbstractNode {
 						'vHWin=window.open(' . GeneralUtility::quoteJSvalue($url) . '+\'&P[currentValue]=\'+TBE_EDITOR.rawurlencode(' .
 								'document.editform[' . GeneralUtility::quoteJSvalue($itemName) . '].value,200' .
 							')' .
-							'+\'&P[currentSelectedValues]=\'+TBE_EDITOR.curSelected(' . GeneralUtility::quoteJSvalue($itemName . $listFlag) . '),' .
+							'+\'&P[currentSelectedValues]=\'+TBE_EDITOR.curSelected(' . GeneralUtility::quoteJSvalue($itemName) . '),' .
 							GeneralUtility::quoteJSvalue('popUp' . $md5ID) . ',' .
 							GeneralUtility::quoteJSvalue($wizardConfiguration['JSopenParams']) .
 						');' .
@@ -351,7 +351,7 @@ abstract class AbstractFormElement extends AbstractNode {
 						'vHWin=window.open('. GeneralUtility::quoteJSvalue($url) . '+\'&P[currentValue]=\'+TBE_EDITOR.rawurlencode(' .
 							'document.editform[' . GeneralUtility::quoteJSvalue($itemName) . '].value,200' .
 							')' .
-							'+\'&P[currentSelectedValues]=\'+TBE_EDITOR.curSelected(' . GeneralUtility::quoteJSvalue($itemName . $listFlag) . '),' .
+							'+\'&P[currentSelectedValues]=\'+TBE_EDITOR.curSelected(' . GeneralUtility::quoteJSvalue($itemName) . '),' .
 							GeneralUtility::quoteJSvalue('popUp' . $md5ID) . ',' .
 							GeneralUtility::quoteJSvalue($wizardConfiguration['JSopenParams']) .
 						');' .
diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/jsfunc.tbe_editor.js b/typo3/sysext/backend/Resources/Public/JavaScript/jsfunc.tbe_editor.js
index dd23dd606365..c3ac59f29306 100644
--- a/typo3/sysext/backend/Resources/Public/JavaScript/jsfunc.tbe_editor.js
+++ b/typo3/sysext/backend/Resources/Public/JavaScript/jsfunc.tbe_editor.js
@@ -276,7 +276,7 @@ var TBE_EDITOR = {
 		return (theStr.substring(sPos+lengthOfDelim,ePos));
 	},
 	curSelected: function(theField) {
-		var fObjSel = document[TBE_EDITOR.formname][theField];
+		var fObjSel = TYPO3.jQuery('select[data-formengine-input-name="' + theField + '"]').get(0);
 		var retVal="";
 		if (fObjSel) {
 			if (fObjSel.type=='select-multiple' || fObjSel.type=='select-one') {
-- 
GitLab