Bug #66588

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

Added by Simon Schaufelberger about 6 years ago. Updated over 3 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!

#1

Updated by Simon Schaufelberger about 6 years ago

example data for options in controller:

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

Updated by Simon Schaufelberger about 6 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
#4

Updated by Jan Helke about 6 years ago

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

Updated by Gerrit Code Review about 6 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

#6

Updated by Gerrit Code Review about 6 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

#7

Updated by Gerrit Code Review about 6 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

#8

Updated by Benni Mack almost 6 years ago

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

Updated by Christian Kuhn almost 6 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/

#10

Updated by Susanne Moog almost 6 years ago

  • Complexity set to easy
#11

Updated by Simon Schaufelberger almost 6 years ago

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

#12

Updated by Susanne Moog almost 6 years ago

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

Updated by Gerrit Code Review almost 6 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

#14

Updated by Markus Günther almost 6 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.

#15

Updated by Gerrit Code Review almost 6 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

#16

Updated by Gerrit Code Review almost 6 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

#17

Updated by Gerrit Code Review almost 6 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

#18

Updated by Markus Günther almost 6 years ago

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

Updated by Anja Leichsenring over 5 years ago

  • Sprint Focus deleted (On Location Sprint)
#20

Updated by Riccardo De Contardi over 3 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF