Validation of type=check in backend on required

Viewed 63

How can you validate a checkbox field that it has to be a required field? Following code doesn't work in TYPO3 V10.4.12:

'teaching_languages' => [
    'label' => 'teaching_languages',
    'config' => [
        'type' => 'check',
        'items' => [
            ['de','1'],
            ['en','2'],
            ['it','3'],
            ['fr','4'],
        ],
        'cols' => 'inline',
        'eval' => 'required'
    ],
],

Is there an easy way to achive it or is this a bug? Any help is appreciated. Thanks in advance.

1 Answers

I assume that you want to check for at least one checked checkbox. That's not possible with 'type' => 'check'.

I'd suggest to switch to 'type' => 'select' with render type 'renderType' => 'selectMultipleSideBySide' or 'renderType' => 'selectCheckBox'.

There you can set minitems to 1 to require at least one selection.

See the documentation for details:

Related