[BUGFIX] indexed_search renders HTML5 placeholder regardless of sword 86/49186/4
authorDaniel Neugebauer <dneuge@glutrot.de>
Mon, 25 Jul 2016 11:11:38 +0000 (13:11 +0200)
committerJan Helke <typo3@helke.de>
Thu, 6 Oct 2016 08:57:43 +0000 (10:57 +0200)
If DocType is HTML5, placeholder attribute on sword input field is now
rendered regardless of sword being empty or not.

Resolves: #77238
Releases: 7.6
Change-Id: If9b31331e7941e5c9068f6f3e73d448fab4905cd
Reviewed-on: https://review.typo3.org/49186
Reviewed-by: Dmitry Dulepov <dmitry.dulepov@gmail.com>
Tested-by: Dmitry Dulepov <dmitry.dulepov@gmail.com>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Jan Helke <typo3@helke.de>
Tested-by: Jan Helke <typo3@helke.de>
typo3/sysext/indexed_search/Classes/Controller/SearchFormController.php

index 4173ef6..598ca52 100644 (file)
@@ -1361,15 +1361,17 @@ class SearchFormController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin
         // Adding search field value
         $markerArray['###SWORD_VALUE###'] = '';
         $markerArray['###PLACEHOLDER###'] = '';
+        $isHTML5 = $GLOBALS['TSFE']->config['config']['doctype'] === 'html5';
         if (!empty($this->piVars['sword'])) {
             $markerArray['###SWORD_VALUE###'] = htmlspecialchars($this->piVars['sword']);
-        } else {
-            // Add a HTML5 placeholder attribute if the configured doctype allows it
-            if ($GLOBALS['TSFE']->config['config']['doctype'] === 'html5') {
-                $markerArray['###PLACEHOLDER###'] = 'placeholder="' . $this->pi_getLL('default_search_word_entry') . '"';
-            } else {
-                $markerArray['###SWORD_VALUE###'] = $this->pi_getLL('default_search_word_entry');
-            }
+        } elseif (!$isHTML5) {
+            // only use placeholder as default value if we cannot use
+            // HTML5 placeholder attribute
+            $markerArray['###SWORD_VALUE###'] = htmlspecialchars($this->pi_getLL('default_search_word_entry'));
+        }
+        // Add a HTML5 placeholder attribute if the configured doctype allows it
+        if ($isHTML5) {
+            $markerArray['###PLACEHOLDER###'] = 'placeholder="' . htmlspecialchars($this->pi_getLL('default_search_word_entry')) . '"';
         }
         // Additonal keyword => "Add to current search words"
         if ($this->conf['show.']['clearSearchBox'] && $this->conf['show.']['clearSearchBox.']['enableSubSearchCheckBox']) {