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

Screenshot of field tx_styleguide_elements_select:select_checkbox_3

Screenshot of field tx_styleguide_elements_select:select_checkbox_3

The select checkbox stores the values as comma separated values.

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

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

Select values from a checkbox list

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.

      'checkbox_3' => [ 
         'exclude' => 1,
         'label' => 'checkbox_3',
         'description' => 'three checkboxes, two with labels, one without',
         'config' => [ 
            'type' => 'check',
            'items' => [ 
               '0' => [ 
                  '0' => 'foo',
                  '1' => '',
               ],
               '1' => [ 
                  '0' => '',
                  '1' => '',
               ],
               '2' => [ 
                  '0' => 'foobar',
                  '1' => '',
                  'iconIdentifierChecked' => 'content-beside-text-img-below-center',
                  'iconIdentifierUnchecked' => 'content-beside-text-img-below-center',
               ],
            ],
         ],
      ],
      // Example from extension "styleguide", table "tx_styleguide_elements_basic"

The field in the database is of type int.