From d25dcc68a3ac6657919a6cee7aa4d361df97e24e Mon Sep 17 00:00:00 2001
From: Christian Kuhn <lolli@schwarzbu.ch>
Date: Fri, 14 Jan 2011 22:50:46 +0000
Subject: [PATCH] Fixed bug #17042: Double class attribute for select tag of
 tceforms "type=select" if using icons

git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@10082 709f56b5-9817-0410-a4d7-c38de5d9e867
---
 ChangeLog                      | 1 +
 t3lib/class.t3lib_tceforms.php | 9 +++++++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a267f29a51f9..b71d3c225b6f 100755
--- a/ChangeLog
+++ b/ChangeLog
@@ -15,6 +15,7 @@
 
 2011-01-14  Christian Kuhn  <lolli@schwarzbu.ch>
 
+	* Fixed bug #17042: Double class attribute for select tag of tceforms "type=select" if using icons
 	* Fixed bug #17036: Misleading deprecation comment getReferenceHTML()
 	* Fixed bug #17034: Live search also returns records which not available to the user (Thanks to Peter Beernink)
 	* Follow-up to #17032: Remove early return
diff --git a/t3lib/class.t3lib_tceforms.php b/t3lib/class.t3lib_tceforms.php
index e2b3601bc35a..3856be99c7b2 100644
--- a/t3lib/class.t3lib_tceforms.php
+++ b/t3lib/class.t3lib_tceforms.php
@@ -1635,6 +1635,7 @@ class t3lib_TCEforms {
 			// Traverse the Array of selector box items:
 		$optGroupStart = array();
 		$optGroupOpen = FALSE;
+		$classesForSelectTag = array();
 		foreach ($selItems as $p) {
 			$sM = (!strcmp($PA['itemFormElValue'], $p[1]) ? ' selected="selected"' : '');
 			if ($sM) {
@@ -1648,7 +1649,8 @@ class t3lib_TCEforms {
 				if ($sM) {
 					list($selectIconFile, $selectIconInfo) = $this->getIcon($p[2]);
 					if (!empty($selectIconInfo)) {
-						$selectedStyle = ' class="typo3-TCEforms-select-selectedItemWithBackgroundImage" style="background-image:url(' . $selectIconFile . ');"';
+						$selectedStyle = ' style="background-image:url(' . $selectIconFile . ');"';
+						$classesForSelectTag[] = 'typo3-TCEforms-select-selectedItemWithBackgroundImage';
 					}
 				}
 			}
@@ -1720,8 +1722,11 @@ class t3lib_TCEforms {
 		if (!$disabled) {
 			$item .= '<input type="hidden" name="' . $PA['itemFormElName'] . '_selIconVal" value="' . htmlspecialchars($sI) . '" />'; // MUST be inserted before the selector - else is the value of the hiddenfield here mysteriously submitted...
 		}
+		if ($config['iconsInOptionTags']) {
+			$classesForSelectTag[] = 'icon-select';
+		}
 		$item .= '<select' . $selectedStyle . ' id="' . uniqid('tceforms-select-') . '" name="' . $PA['itemFormElName'] . '"' .
-				 ($config['iconsInOptionTags'] ? $this->insertDefStyle('select', 'icon-select') : $this->insertDefStyle('select')) .
+				 $this->insertDefStyle('select', implode(' ', $classesForSelectTag)) .
 				 ($size ? ' size="' . $size . '"' : '') .
 				 ' onchange="' . htmlspecialchars($onChangeIcon . $sOnChange) . '"' .
 				 $PA['onFocus'] . $disabled . '>';
-- 
GitLab