Bug #77257

Story #69617: FormEngine bugs

The selection of a selectbox with the l10n_display type of defaultAsReadonly in TCA is wrong for a localized record

Added by M. Stichweh over 3 years ago. Updated 6 months ago.

Status:
New
Priority:
Must have
Assignee:
-
Category:
FormEngine aka TCEforms
Start date:
2016-07-26
Due date:
% Done:

0%

TYPO3 Version:
7
PHP Version:
5.6
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

If a non-translatable selectbox is rendered within a localized record with defaultAsReadonly type for l10n_display only the first character of the selected uid is used to set the selected value. The problem is in line 95 of the SelectSingleElement class:

if (!empty($parameterArray['itemFormElValue'])) {
    $selectedValue = (string)$parameterArray['itemFormElValue'][0];
}

An array is expected here but in this case, a localized item with a non-translatable select field, the value of itemFormElValue is a string.

Here is an example for the TCA config:

'foo' => array(
  'l10n_mode' => 'exclude',
  'l10n_display' => 'defaultAsReadonly',
  'config' => array(
    'type' => 'select',
    'renderType' => 'selectSingle',
    'foreign_table' => 'tx_example_domain_model_foo'
  )
)

Related issues

Related to TYPO3 Core - Bug #77155: PHP Warning: Invalid argument supplied for foreach() in backend/Classes/Form/Element/SelectMultipleSideBySideElement.php line 66 Closed 2016-07-19
Related to TYPO3 Core - Bug #84997: Localized records with rendertype selectCheckBox + defaultAsReadonly generate PHP warnings New 2018-05-14
Related to TYPO3 Core - Bug #82843: TCA: localized `SelectSingleElement` selects wrong option New 2017-10-23
Duplicates TYPO3 Core - Bug #76785: Wrong Selected option in localised TCA columns of type select when l10n_mode="exclude" New 2016-06-24

History

#1 Updated by Markus Klein over 3 years ago

  • Status changed from New to Needs Feedback

I'm not sure about your usecase.
While I agree that the value of the option is not nice to be just a character, I have to ask what the intention is.
If a fields is an excluded one, no value at all should be stored into DB (not sure if that is the case currently though) or at least on evaluation in FE always the value of the parent record will be taken, the actual value in the translation does not matter.

#2 Updated by M. Stichweh over 3 years ago

Markus Klein wrote:

I'm not sure about your usecase.
While I agree that the value of the option is not nice to be just a character, I have to ask what the intention is.
If a fields is an excluded one, no value at all should be stored into DB (not sure if that is the case currently though) or at least on evaluation in FE always the value of the parent record will be taken, the actual value in the translation does not matter.

For example you could have a list of books and for each book you have to select an author. The author is selected by a selectbox which is filled by another table. The author field is not localizable and can only be selected in the default language of the book. If this field is configured with defaultAsReadonly for l10n_display the author should be displayed in a localized dataset of a book. The authors table has the items "John Doe" with uid 123 and "Jane Doe" with uid 1. If you select the author "John Doe" with uid 123 only uid 1 is used to select the author in a localized book. So in the localized version of the book "Jane Doe" is displayed.

#3 Updated by Markus Klein over 3 years ago

  • Status changed from Needs Feedback to New
  • Priority changed from Should have to Must have
  • Target version set to Candidate for patchlevel

#4 Updated by Christian Futterlieb over 2 years ago

I have quite the same problem with a select field with a defined set of items (no foreign_table). In my case, the first item is shown as selected value in the localized version (instead of the value of the original). Appears in TYPO3 7.6 and 8.6.1.

'duplicationCheck' => [
    'exclude' => true,
    'label' => 'Duplication test',
    'l10n_mode' => 'exclude',
    'l10n_display' => 'defaultAsReadonly',
    'config' => [
        'type' => 'select',
        'renderType' => 'selectSingle',
        'items' => [
            [
                'Test by IP',
                'ip'
            ],
            [
                'Test by cookie',
                'cookie'
            ],
            [
                'Foo test',
                'foo'
            ],
            [
                'None',
                ''
            ]
        ],
        'default' => 'cookie'
    ]
]

Additionally I recognised, that in TYPO3 7.6 the field value gets copied to the translated record with the configured default value, while in TYPO3 8.6.1 the selected value is used. Don't know whether this is intended or not (or even related to this task), just for you to know :-)

#5 Updated by Christian Kuhn over 2 years ago

  • Parent task set to #69617

#6 Updated by Loon Buster over 2 years ago

..are there any news about this?

.loon

#7 Updated by Michael Stopp over 1 year ago

  • Related to Bug #84997: Localized records with rendertype selectCheckBox + defaultAsReadonly generate PHP warnings added

#8 Updated by Andreas Krämer 9 months ago

  • Duplicates Bug #76785: Wrong Selected option in localised TCA columns of type select when l10n_mode="exclude" added

#9 Updated by Andreas Krämer 9 months ago

  • Related to Bug #82843: TCA: localized `SelectSingleElement` selects wrong option added

#10 Updated by Thomas Deinhamer 6 months ago

Just encountered this with TYPO3 8.7.24 - the option in the localized record is not selected correctly; it just uses/shows the default/first option.

Also available in: Atom PDF