Default checkbox

The checkbox with renderType check is typically a single checkbox or a group of checkboxes.

Its state can be inverted via invertStateDisplay.

Examples

All examples listed here can be found in the extension styleguide.

Example: Simple checkbox with label

TCA:

EXT:styleguide/Configuration/TCA/tx_styleguide_elements_basic.php
[
    'columns' => [
        'checkbox_2' => [
            'exclude' => 1,
            'label' => 'checkbox_2',
            'description' => 'one checkbox with label',
            'config' => [
                'type' => 'check',
                'items' => [
                    [
                        'foo',
                    ],
                ],
            ],
        ],
    ],
]
Copied!

If the checkbox is checked, the value for the field will be 1, if unchecked, it will be 0.

FlexForm:

EXT:styleguide/Configuration/TCA/tx_styleguide_flex.php
<checkbox_2>
   <TCEforms>
       <label>checkbox_2 cols=3</label>
       <config>
           <type>check</type>
           <items type="array">
               <numIndex index="0" type="array">
                   <numIndex index="0">foo1</numIndex>
                   <numIndex index="1"></numIndex>
               </numIndex>
               <numIndex index="1" type="array">
                   <numIndex index="0">foo2</numIndex>
                   <numIndex index="1"></numIndex>
               </numIndex>
               <numIndex index="2" type="array">
                   <numIndex index="0">foo3</numIndex>
                   <numIndex index="1"></numIndex>
               </numIndex>
               <numIndex index="3" type="array">
                   <numIndex index="0">foo4</numIndex>
                   <numIndex index="1"></numIndex>
               </numIndex>
           </items>
           <cols>3</cols>
       </config>
   </TCEforms>
</checkbox_2>
Copied!

Example: Four checkboxes in three columns

TCA:

EXT:styleguide/Configuration/TCA/tx_styleguide_elements_basic.php
[
    'columns' => [
        'checkbox_12' => [
            'exclude' => 1,
            'label' => 'checkbox_12',
            'description' => 'cols=3',
            'config' => [
                'type' => 'check',
                'items' => [
                    [
                        'foo1',
                    ],
                    [
                        'foo2',
                    ],
                    [
                        'foo3',
                    ],
                    [
                        'foo4',
                    ],
                ],
                'cols' => '3',
            ],
        ],
    ],
]
Copied!

If all checkboxes are checked, the value for the field will be 15 (1 | 2 | 4 | 8).

Example: Checkboxes with inline floating

EXT:styleguide/Configuration/TCA/tx_styleguide_elements_basic.php
[
    'columns' => [
        'checkbox_16' => [
            'exclude' => 1,
            'label' => 'checkbox_16',
            'description' => 'cols=inline',
            'config' => [
                'type' => 'check',
                'items' => [
                    [
                        'Mo',
                    ],
                    [
                        'Tu',
                    ],
                    [
                        'We',
                    ],
                    [
                        'Th',
                    ],
                    [
                        'Fr',
                    ],
                    [
                        'Sa',
                    ],
                    [
                        'Su',
                    ],
                ],
                'cols' => 'inline',
            ],
        ],
    ],
]
Copied!

This will display as many checkbox items as will fit in one row. Without inline, each checkbox would be displayed in a separate row.