Bug #92599

OptionViewHelper

Added by Reindl Bernd about 1 year ago. Updated about 2 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Fluid
Target version:
Start date:
2020-10-19
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
10
PHP Version:
7.2
Tags:
Complexity:
easy
Is Regression:
Sprint Focus:

Description

isValueSelected() in \TYPO3\CMS\Fluid\ViewHelpers\Form\Select\OptionViewHelper compares $value with $selectedValue.

$value is always a string. $selectedValue can be a integer too. So $value === $selectedValue returns false if $value is 3 (string) and $selectedValue is 3 (int).

In my case $selectedValue is the property status from a domain object (inquiry).


    /**
     * @var int
     */
    protected $status;

the form is created by fluid

<f:form action="saveInquiry" object="{inquiry}" objectName="inquiry" arguments="{inquiry: inquiry, serializedFilter: serializedFilter}">
...
<f:form.select property="status">                                
  <f:form.select.option value="1">{f:translate(key:'inquiry.status.1')}</f:form.select.option>
  <f:form.select.option value="3">{f:translate(key:'inquiry.status.3')}</f:form.select.option>
  <f:form.select.option value="4">{f:translate(key:'inquiry.status.4')}</f:form.select.option>
  <f:form.select.option value="5">{f:translate(key:'inquiry.status.5')}</f:form.select.option>
  <f:form.select.option value="6">{f:translate(key:'inquiry.status.6')}</f:form.select.option>
</f:form.select>
...
</f:form>

i have solved it by replacing === with ==


Related issues

Related to TYPO3 Core - Bug #93801: The select Viewhelper isn't selecting the correct value from a domain model.Closed2021-03-22

Actions
#1

Updated by Benni Mack about 2 months ago

  • Related to Bug #93801: The select Viewhelper isn't selecting the correct value from a domain model. added
#2

Updated by Benni Mack about 2 months ago

  • Status changed from New to Needs Feedback

This should be fixed with #93801 - can you confirm this?

#3

Updated by Reindl Bernd about 2 months ago

Benni Mack wrote in #note-2:

This should be fixed with #93801 - can you confirm this?

Yes. This should solve the issue.

#4

Updated by Benni Mack about 2 months ago

  • Status changed from Needs Feedback to Closed

Thanks for checking

Also available in: Atom PDF