Resolves #59459: SelectViewHelper: DefaultOptionValue and Label with no effect (Thank...
authorstan <stan@735d13b6-9817-0410-8766-e36946ffe9aa>
Tue, 29 Jul 2014 20:17:04 +0000 (20:17 +0000)
committerstan <stan@735d13b6-9817-0410-8766-e36946ffe9aa>
Tue, 29 Jul 2014 20:17:04 +0000 (20:17 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/static_info_tables/trunk@86062 735d13b6-9817-0410-8766-e36946ffe9aa

ChangeLog
Classes/ViewHelpers/Form/SelectViewHelper.php

index 6a20951..6e592d0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 2014-07-29  Stanislas Rolland  <typo3@sjbr.ca>
 
        * Resolves #60666: Outdated data for Turkish lira
+       * Resolves #59459: SelectViewHelper: DefaultOptionValue and Label with no effect (Thanks to Thomas Löffler)
 
 2014-06-03  Stanislas Rolland  <typo3@sjbr.ca>
 
index f59f23e..e7884f1 100644 (file)
@@ -186,7 +186,14 @@ class SelectViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\SelectViewHelpe
                }
                $this->arguments['options'] = $options;
 
-               return parent::getOptions();
+               $sortedOptions = parent::getOptions();
+               // Put default option after sorting to get it to the top of the items
+               if ($this->hasArgument('defaultOptionLabel')) {
+                       $defaultOptionLabel = $this->arguments['defaultOptionLabel'];
+                       $defaultOptionValue = $this->hasArgument('defaultOptionValue') ? $this->arguments['defaultOptionValue'] : 0;
+                       $sortedOptions = array($defaultOptionValue => $defaultOptionLabel) + $sortedOptions;
+               }
+               return $sortedOptions;
        }
 
        /**