Issue Bug Closed

#92599OptionViewHelper

Reindl Bernd 10/19/20, 11:46 updated 10/11/21, 07:56

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

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.