selectCheckBox and type check fields compared

There is a subtle difference between select fields with the render type selectCheckBox and fields of the type check:

Select values from a checkbox list

../../../../_images/SelectCheckbox3.png

The select checkbox stores the values as comma separated values.

'columns' => [
    'select_checkbox_3' => [
        'exclude' => 1,
        'label' => 'select_checkbox_3 icons, description',
        'config' => [
            'type' => 'select',
            'renderType' => 'selectCheckBox',
            'items' => [
                [
                    'foo 1',
                    1,
                    '',
                    null,
                    [
                        'title' => 'optional title',
                        'description' => 'optional description',
                    ],
                ],
                [
                    'foo 2',
                    2,
                    'EXT:styleguide/Resources/Public/Icons/tx_styleguide.svg',
                    null,
                    'LLL:EXT:styleguide/Resources/Private/Language/locallang.xlf:translatedHelpTextForSelectCheckBox3',
                ],
                [
                    'foo 3',
                    3,
                    'EXT:styleguide/Resources/Public/Icons/tx_styleguide.svg',
                ],
                [
                    'foo 4',
                    4,
                ],
            ],
        ],
    ],
]

The field in the database is of type text or varchar.

Select values from a checkbox list

../../../../_images/Checkbox3.png

On the contrary the type check saves multiple values as bits. Therefore if the first value is chosen it stores 1, if only the second is chosen it stores 2 and if both are chosen 3.

'columns' => [
    'checkbox_3' => [
        'exclude' => 1,
        'label' => 'checkbox_3',
        'description' => 'three checkboxes, two with labels, one without',
        'config' => [
            'type' => 'check',
            'items' => [
                [
                    'foo',
                    '',
                ],
                [
                    '',
                    '',
                ],
                [
                    0 => 'foobar',
                    1 => '',
                    'iconIdentifierChecked' => 'content-beside-text-img-below-center',
                    'iconIdentifierUnchecked' => 'content-beside-text-img-below-center',
                ],
            ],
        ],
    ],
]

The field in the database is of type int.