Project

General

Profile

Actions

Bug #66588

closed

POST Data in selectviewhelper should have higher priority than "value" value

Added by Simon Schaufelberger over 9 years ago. Updated about 7 years ago.

Status:
Closed
Priority:
Must have
Assignee:
Category:
Fluid
Target version:
Start date:
2015-04-25
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
7
PHP Version:
Tags:
Complexity:
easy
Is Regression:
No
Sprint Focus:

Description

given the following fluid:

<f:form.select name="myname" options="{myoptions}" value="50" />

and submitting the form with an error, the item with value 50 is always selected no matter what other value i selected before.

I would call value a default value and not a "always select" value.

A workaround would of course be to make "value" also a variable and handle the default and overwrite stuff in controller but this is really ugly!

here lies the problem: https://git.typo3.org/Packages/TYPO3.CMS.git/blob/HEAD:/typo3/sysext/fluid/Classes/ViewHelpers/Form/AbstractFormFieldViewHelper.php#l106

first the value is checked if it exists but never $value = $this->getLastSubmittedFormData(); in the case value is not an object itself.

Expected result:
POST Data should be checked BEFORE the default value is returned.

If possible please backport this bug to older TYPO3 versions!

Actions #1

Updated by Simon Schaufelberger over 9 years ago

example data for options in controller:

$options = array(
    1 => one,
    50 => fifty,
    51 => fiftyone
);
$this->view->assign('myoptions', $options);
Actions #3

Updated by Simon Schaufelberger over 9 years ago

patch idea for getValue for TYPO3 pre 6.0, below for > 6.0 ;)

if ($this->hasArgument('value')) {
    $request = $this->controllerContext->getRequest();
    if ($request instanceof Tx_Extbase_MVC_Web_Request && $request->getMethod() === 'POST') {
        $value = t3lib_div::_POST($this->arguments['name']);
    } else {
        $value = $this->arguments['value'];
    }
}

if ($this->hasArgument('value')) {
    $request = $this->controllerContext->getRequest();
    if ($request instanceof \TYPO3\CMS\Extbase\Mvc\Web\Request && $request->getMethod() === 'POST') {
        $value = \TYPO3\CMS\Core\Utility\GeneralUtility::_POST($this->arguments['name']);
    } else {
        $value = $this->arguments['value'];
    }
}

if this looks ok, I will push it to gerrit
Actions #4

Updated by Jan Helke over 9 years ago

  • Assignee set to Jan Helke
  • Target version set to 7.3 (Packages)
  • Sprint Focus set to On Location Sprint
Actions #5

Updated by Gerrit Code Review over 9 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/39155

Actions #6

Updated by Gerrit Code Review over 9 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/39155

Actions #7

Updated by Gerrit Code Review over 9 years ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/39155

Actions #8

Updated by Benni Mack over 9 years ago

  • Target version changed from 7.3 (Packages) to 7.4 (Backend)
Actions #9

Updated by Christian Kuhn over 9 years ago

  • Status changed from Under Review to New

The pending patch was abandoned, the approach does not work.

The issue is still valid, a good entry point is the patch that solved the same (or at least related) issue in flow: https://review.typo3.org/#/c/24794/

Actions #10

Updated by Susanne Moog over 9 years ago

  • Complexity set to easy
Actions #11

Updated by Simon Schaufelberger over 9 years ago

since this is merged in flow, can this be backported in this ticket?

Actions #12

Updated by Susanne Moog over 9 years ago

  • Target version changed from 7.4 (Backend) to 7.5
Actions #13

Updated by Gerrit Code Review over 9 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/42298

Actions #14

Updated by Markus Günther over 9 years ago

I created a small test extension...
https://github.com/markusguenther/mg_testforms

Hope that helps a bit. I need to fix the unit tests a bit.

Actions #15

Updated by Gerrit Code Review over 9 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/42298

Actions #16

Updated by Gerrit Code Review over 9 years ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/42298

Actions #17

Updated by Gerrit Code Review over 9 years ago

Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/42298

Actions #18

Updated by Markus Günther over 9 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #19

Updated by Anja Leichsenring almost 9 years ago

  • Sprint Focus deleted (On Location Sprint)
Actions #20

Updated by Riccardo De Contardi about 7 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF