[BUGFIX] EXT:form - Selected attribute not rendered 94/44394/2
authorRalf Zimmermann <ralf.zimmermann@tritum.de>
Fri, 30 Oct 2015 12:33:06 +0000 (13:33 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sat, 31 Oct 2015 11:31:05 +0000 (12:31 +0100)
Pass the selected values to the select viewhelper "value" attribute.

Resolves: #70502
Releases: master
Change-Id: Id0ac372b2598a0ed2ea1f6cc3dbef90668915d77
Reviewed-on: https://review.typo3.org/44394
Reviewed-by: Bjoern Jacob <bjoern.jacob@tritum.de>
Tested-by: Bjoern Jacob <bjoern.jacob@tritum.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/form/Classes/Hooks/HandleIncomingFormValues.php
typo3/sysext/form/Classes/ViewHelpers/AggregateSelectOptionsViewHelper.php
typo3/sysext/form/Resources/Private/Partials/Compatibility/Show/FlatElements/Select.html
typo3/sysext/form/Resources/Private/Partials/Default/Show/FlatElements/Select.html

index cd850b8..a6eb9f4 100644 (file)
@@ -122,18 +122,19 @@ class HandleIncomingFormValues implements SingletonInterface
                 $parentName = $element->getParentElement()->getName();
             }
             $incomingData = $formBuilder->getIncomingData()->getIncomingField($parentName);
+
             /* Multiselect */
             if (is_array($incomingData)) {
                 if (in_array($modelValue, $incomingData, true)) {
-                    $element->setHtmlAttribute('selected', 'selected');
+                    $element->setAdditionalArgument('selected', 'selected');
                 } else {
-                    $element->setHtmlAttribute('selected', null);
+                    $element->setAdditionalArgument('selected', null);
                 }
             } else {
                 if ($modelValue === $incomingData) {
-                    $element->setHtmlAttribute('selected', 'selected');
+                    $element->setAdditionalArgument('selected', 'selected');
                 } else {
-                    $element->setHtmlAttribute('selected', null);
+                    $element->setAdditionalArgument('selected', null);
                 }
             }
         } elseif ($element->getElementType() === 'TEXTAREA') {
index 61c3225..c2f648f 100644 (file)
@@ -70,14 +70,14 @@ class AggregateSelectOptionsViewHelper extends AbstractViewHelper
         if ($model->getElementType() === 'OPTGROUP') {
             $optGroupData = array(
                 'label' => $model->getAdditionalArgument('label'),
-                'disabled' => $model->getHtmlAttribute('disabled')
+                'disabled' => $model->getAdditionalArgument('disabled')
             );
             $this->getChildElements($model, $optGroupData);
         } else {
             $optionData = array(
                 'value' => $model->getAdditionalArgument('value') ?: $model->getElementCounter(),
                 'label' => $model->getAdditionalArgument('text'),
-                'selected' => $model->getHtmlAttribute('selected'),
+                'selected' => $model->getAdditionalArgument('selected'),
             );
 
             if (!empty($optionData['selected'])) {
index 494df69..77bec13 100644 (file)
@@ -14,7 +14,7 @@
                        onclick="{model.additionalArguments.onclick}"
 
                        name="{model.additionalArguments.prefix}[{model.additionalArguments.name}]"
-                       value="{model.additionalArguments.value}"
+                       value="{form:aggregateSelectOptions(model:model, returnSelectedValues: 1)}"
 
                        multiple="{model.additionalArguments.multiple}"
                        size="{model.additionalArguments.size}"
index 3dd57d0..b305e28 100644 (file)
@@ -24,7 +24,7 @@
                        onclick="{model.additionalArguments.onclick}"
 
                        name="{model.additionalArguments.prefix}[{model.additionalArguments.name}]"
-                       value="{model.additionalArguments.value}"
+                       value="{form:aggregateSelectOptions(model:model, returnSelectedValues: 1)}"
 
                        multiple="{model.additionalArguments.multiple}"
                        size="{model.additionalArguments.size}"
@@ -41,4 +41,4 @@
                        additionalAttributes="{model.htmlAttributes}"
                />
        </li>
-</f:if>
\ No newline at end of file
+</f:if>