#60908Provide Evaluation of TCA select fields
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.
Related issues 4
- Bug #60247eval=>"required" not working with select fields
- Bug #94050Do not reload form on change if mandatory fields are not filled in
- Bug #99153Discrepancy between behaviour and documentation for "eval" property in "select" fields in TCA
- Feature #111518Add placeholder option for TCA select fields with renderType selectSingle
Files 1
History 12
-
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. -
Martin Sonnenholzer commented <span data-processor="relativetime" data-value="2014-08-14T11:43:13+00:00" > 08/14/14, 11:43 </span>
+1 I had that problem a few times
-
Felix Kopp changed tracker
BugFeature category <span data-processor="relativetime" data-value="2014-12-13T14:31:24+00:00" > 12/13/14, 14:31 </span> -
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’, -
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.htmlAnd 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.
-
Sybille Peters changed Related to #94050 <span data-processor="relativetime" data-value="2022-11-21T12:04:46+00:00" > 11/21/22, 12:04 </span>
-
Sybille Peters changed Related to #99153 <span data-processor="relativetime" data-value="2022-11-21T12:15:57+00:00" > 11/21/22, 12:15 </span>
-
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:
- 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)” - 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.
-
Benni Mack commented and changed status
NewClosed <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' => trueis a top-level TCA config option that FormEngine also applies totype=select. AselectSinglewith a “please choose” item with value''and'required' => truecannot 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
requiredfor select fields, and a placeholder with value0is not treated as empty. If that is needed, please open a new, focused issue.Closing this one as resolved.
-
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' => trueis a top-level TCA config option that FormEngine also applies totype=select. AselectSinglewith a “please choose” item with value''and'required' => truecannot 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 enforcerequiredfor select fields, and a placeholder with value0is 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.
-
Nikita Hovratov changed Related to #111518 <span data-processor="relativetime" data-value="2026-11-20T15:10:40+00:00" > 11/20/26, 15:10 </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.