Issue Feature Closed

#60908Provide Evaluation of TCA select fields

Moritz Ahl 08/12/14, 11:55 updated 11/20/26, 13:51

Description

Currently, it is not possible to require a (single) select field as mandatory, meaning non-empty or required in TCA. An “eval” property simply does not exist and is ignored if given.

Example:

'owner' => array(
        'exclude' => 1,
        'exclude' => 0,
        'label' => 'Owner',
        'config' => array(
                        'type' => 'select',
                        'foreign_table' => 'tx_myext_domain_model_owner',
                        'size' => 1,
                        'autoSizeMax' => 30,
                        'items' => array(
                                array('', ''),
                        ),
                    'maxitems' => 1,
                        'minitems' => 1,
                        'multiple' => 0,
                        'eval' => 'required,notEmpty'
        ),
),

That is really lame :-) A CMS must provide at least basic evaluation options for all input types.

Reviews 0

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

Files 1

History 12

  1. Benjamin Rau commented <span data-processor="relativetime" data-value="2014-08-12T12:02:26+00:00" > 08/12/14, 12:02 </span>

    I agree, you can only work around this actually by forcing the select to multiselect (size>1).
    Beeing able to make a single select with empty default option mandatory is a must have for me, too.

  2. Anonymous commented <span data-processor="relativetime" data-value="2014-08-12T12:04:11+00:00" > 08/12/14, 12:04 </span>

    +1
    I think this feature should be a must have for TYPO3.

  3. Krzysztof Napora commented <span data-processor="relativetime" data-value="2017-03-24T12:45:20+00:00" > 03/24/17, 12:45 </span>

    ‘minitems’ => 1,
    ‘maxitems’ => 1,
    ‘eval’ => ‘required’,

  4. Gernot Ploiner commented <span data-processor="relativetime" data-value="2022-11-21T09:44:48+00:00" > 11/21/22, 09:44 </span>

    What you are looking for is:

    ...
    'items' => array(
            array('Please choose', 0),
    ),
    'eval' => 'required'
    ...

    This works, but it shouldn’t. Because eval is not a setting for type=select.
    See: https://docs.typo3.org/m/typo3/reference-tca/10.4/en-us/ColumnsConfig/Type/selectSingle.html

    And there is a Bug combined with ‘onChange’ => ‘reload’. See: https://forge.typo3.org/issues/94050

    But this is a needed missing feature. Without, it is not possible to make a selectSingle with a “please choose” entry, which is required.
    The Setting ‘minitems=1’ without “please choose” will work, but then you have one of the otions preselected. You cannot force the Editor to select an option.

    The workaround with ‘multiselect>1’ is not beautiful.

    Tested in TYPO3 10.4.

  5. Gernot Ploiner commented and changed attached tcademo.zip <span data-processor="relativetime" data-value="2022-11-27T07:27:36+00:00" > 11/27/22, 07:27 </span>

    I attached a small extension for TYPO3 11.5 (there is the same behavior as in 10.4) to easyly reproduce the two related problems:

    *Installation:*
    Install the extension: ddev composer require webprofil/tcademo:@dev
    In the TYPO3 Backend:
    • create a regular page (e.g. uid=1)
    • create a folder in the pagetree (e.g. uid=2)
    • create a fegroup at the folder
    • create some feusers at the folder
    • create a ‘Dummy’ record at your page or folder

    Now you can see the problems:

    1. Before you save, change the select “Type” to “Type 1”. Then reload (click “yes”). This errormessage apperars, because “Employee” is not filled out:
      “2: SQL error: ‘Incorrect integer value: ‘’ for column `db`.`tx_tcademo_domain_model_dummy`.`employee` at row 1’ (tx_tcademo_domain_model_dummy:NEW63830ddb4a18d611387331)”
    2. The “Employee” select is displayed as I expect. But as I know, the TCA-property ‘eval’ => ‘required’ is not allowed (and not documented) at TCA select / selectSingle. Without eval, it is not possible to make a selectSingle required with a “pleasechoose” option.
  6. Benni Mack commented and changed status New Closed <span data-processor="relativetime" data-value="2026-11-19T10:12:45+00:00" > 11/19/26, 10:12 </span>

    This is possible since TYPO3 v12 (#97035): 'required' => true is a top-level TCA config option that FormEngine also applies to type=select. A selectSingle with a “please choose” item with value '' and 'required' => true cannot be saved until a real option is selected. Core uses this pattern itself, e.g. sys_reaction.reaction_type.

    Note: the check runs only in FormEngine (client side). DataHandler does not enforce required for select fields, and a placeholder with value 0 is not treated as empty. If that is needed, please open a new, focused issue.

    Closing this one as resolved.

  7. Nikita Hovratov commented <span data-processor="relativetime" data-value="2026-11-20T13:51:33+00:00" > 11/20/26, 13:51 </span>

    @benni

    Benni Mack wrote in #note-10:
    > This is possible since TYPO3 v12 (#97035): 'required' => true is a top-level TCA config option that FormEngine also applies to type=select. A selectSingle with a “please choose” item with value '' and 'required' => true cannot be saved until a real option is selected. Core uses this pattern itself, e.g. sys_reaction.reaction_type.
    >
    > Note: the check runs only in FormEngine (client side). DataHandler does not enforce required for select fields, and a placeholder with value 0 is not treated as empty. If that is needed, please open a new, focused issue.
    >
    > Closing this one as resolved.

    This actually worked since 2015 as Gernot wrote: https://forge.typo3.org/issues/60908#note-6

    This is more or less per “accident” and was never really documented. Also the onChange/reload behavior described by Gernot should be checked.

    We should therefore introduce this as a real feature with DataHandler support.