[BUGFIX] Fix suggest wizard item selection 79/31479/2
authorBenoit Chenu <benoit.chenu@gmail.com>
Mon, 2 Jun 2014 11:44:36 +0000 (13:44 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Mon, 7 Jul 2014 21:49:52 +0000 (23:49 +0200)
When selecting an item in a suggest list, the first label is always
taken instead of the clicked one.

Resolves: #55835
Releases: 6.3, 6.2
Change-Id: I7590cb290ee19fd807260ef5767805a23ef088b0
Reviewed-on: https://review.typo3.org/31479
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
typo3/sysext/backend/Resources/Public/JavaScript/jsfunc.tceforms_suggest.js

index c0c5a54..20b2396 100644 (file)
@@ -81,34 +81,22 @@ TCEForms.Suggest = Class.create({
                        var arr = item.id.split('-');
                        var ins_table = arr[0];
                        var ins_uid = arr[1];
+                       var ins_uid_string = (this.fieldType == 'select') ? ins_uid : (ins_table + '_' + ins_uid);
                        var rec_table = arr[2];
                        var rec_uid = arr[3];
                        var rec_field = arr[4];
 
                        var formEl = this.objectId;
-                       var suggestLabelNode = Element.select(this.escapeObjectId(item.id), '.suggest-label')[0];
-                       var label = (suggestLabelNode.textContent ? suggestLabelNode.textContent : suggestLabelNode.innerText)
-                       var ins_uid_string = (this.fieldType == 'select') ? ins_uid : (ins_table + '_' + ins_uid);
 
-                       setFormValueFromBrowseWin(formEl, ins_uid_string, label);
+                       var suggestLabelNode = Element.select(item, '.suggest-label')[0];
+                       var label = suggestLabelNode.textContent ? suggestLabelNode.textContent : suggestLabelNode.innerText;
+                       var suggestLabelTitleNode = Element.select(suggestLabelNode, '[title]')[0];
+                       var title = suggestLabelTitleNode ? suggestLabelTitleNode.readAttribute('title') : '';
+
+                       setFormValueFromBrowseWin(formEl, ins_uid_string, label, title);
                        TBE_EDITOR.fieldChanged(rec_table, rec_uid, rec_field, formEl);
 
                        $(this.suggestField).value = this.defaultValue;
                }
-       },
-
-       /**
-        * Escapes object identifiers of e.g. Flexform CSS IDs
-        *
-        * @param string objectId
-        * @return string
-        */
-       escapeObjectId: function(objectId) {
-               var escapedObjectId;
-               escapedObjectId = objectId.replace(/:/g, '\\:');
-               escapedObjectId = objectId.replace(/\./g, '\\.');
-               escapedObjectId = objectId.replace(/\[/g, '\\[');
-               escapedObjectId = objectId.replace(/\]/g, '\\]');
-               return escapedObjectId;
        }
 });