[BUGFIX] Correctly store values of select fields 13/36813/8
authorNicole Cordes <typo3@cordes.co>
Tue, 10 Feb 2015 21:58:29 +0000 (22:58 +0100)
committerAlexander Opitz <opitz.alexander@googlemail.com>
Wed, 11 Feb 2015 09:36:30 +0000 (10:36 +0100)
Due to a wrong position of the hidden helper field, the values of select
boxes aren't submitted. This patch removes the hidden field as it is
unused anyway.

Furthermore a double encoding of the option value is prevented.

Releases: master
Resolves: #64878
Change-Id: I3b24dd7c8fca41c01748efdeded3356ba9740a42
Reviewed-on: http://review.typo3.org/36813
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
Reviewed-by: Nicole Cordes <typo3@cordes.co>
Tested-by: Nicole Cordes <typo3@cordes.co>
Reviewed-by: Frederic Gaus <gaus@flagbit.de>
Tested-by: Frederic Gaus <gaus@flagbit.de>
Reviewed-by: Alexander Opitz <opitz.alexander@googlemail.com>
Tested-by: Alexander Opitz <opitz.alexander@googlemail.com>
typo3/sysext/backend/Classes/Form/Element/SelectElement.php
typo3/sysext/backend/Resources/Public/JavaScript/jsfunc.tbe_editor.js

index 705354e..6875cb7 100644 (file)
@@ -435,6 +435,7 @@ class SelectElement extends AbstractFormElement {
                $selectItemGroupCount = 0;
                $selectItemGroups = array();
                $selectIcons = array();
+               $selectedValue = '';
                foreach ($selectItems as $item) {
                        if ($item[1] === '--div--') {
                                // IS OPTGROUP
@@ -448,7 +449,6 @@ class SelectElement extends AbstractFormElement {
                        } else {
                                // IS ITEM
                                $title = htmlspecialchars($item['0'], ENT_COMPAT, 'UTF-8', FALSE);
-                               $value = htmlspecialchars($item[1]);
                                $icon = (!empty($item[2]) ? $this->formEngine->getIconHtml($item[2], $title, $title) : '');
                                $selected = ((string)$PA['itemFormElValue'] === (string)$item[1] ? 1 : 0);
                                if ($selected) {
@@ -459,7 +459,7 @@ class SelectElement extends AbstractFormElement {
                                }
                                $selectItemGroups[$selectItemGroupCount]['items'][] = array(
                                        'title' => $title,
-                                       'value' => $value,
+                                       'value' => $item[1],
                                        'icon' => $icon,
                                        'selected' => $selected,
                                        'index' => $selectItemCounter
@@ -538,7 +538,6 @@ class SelectElement extends AbstractFormElement {
                                        . '>
                                        ' . $options . '
                                </select>
-                               ' . (!$disabled ? '<input type="hidden" name="' . $PA['itemFormElName'] . '_selIconVal" value="' . $selectedValue . '" />' : '') . '
                                ' . $append . '
                        </div>';
 
index 7f3bf39..9b5bedd 100644 (file)
@@ -335,12 +335,7 @@ var TBE_EDITOR = {
                var $paletteField = $formField.closest('.t3js-formengine-palette-field');
                $paletteField.addClass('has-change');
 
-               // Set hidden field to value
-               if (document[TBE_EDITOR.formname][theField] && document[TBE_EDITOR.formname][theField].type=="select-one" && document[TBE_EDITOR.formname][theField+"_selIconVal"]) {
-                       document[TBE_EDITOR.formname][theField+"_selIconVal"].value = document[TBE_EDITOR.formname][theField].value;
-               }
-
-                       // Set required flag:
+               // Set required flag:
                var imgReqObjName = "req_"+table+"_"+uid+"_"+field;
                if (TBE_EDITOR.getElement(theRecord,field,'required') && document[TBE_EDITOR.formname][theField]) {
                        if (TBE_EDITOR.checkElements('required', false, theRecord, field)) {