1

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 Answer 1

2

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:

1
  • 2
    Thanks Peter Kraume for your hint. I tried selectCheckBox with TYPO3 V10.4.12 which didn't work! So I found this forge.typo3.org/issues/83457 that gave me the information to use at minimum V10.4.13. After I update my local TYPO3 Version it works with selectCheckBox and minitems=1.
    – Dan
    Apr 14, 2021 at 8:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.