Examples

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

Example: Simple checkbox with label

TCA:

      'checkbox_2' => [ 
         'exclude' => 1,
         'label' => 'checkbox_2 one checkbox with label',
         'config' => [ 
            'type' => 'check',
            'items' => [ 
               '0' => [ 
                  '0' => 'foo',
                  '1' => '',
               ],
            ],
         ],
      ],
      // Example from extension "styleguide", table "tx_styleguide_elements_basic"

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

FlexForm:

                                    </passthrough_2>
                                    <settings.checkbox_2>
                                       <TCEforms>
                                           <label>checkbox_2 one checkbox with label</label>
                                           <config>
                                               <type>check</type>
                                               <items type="array">
                                                   <numIndex index="0" type="array">
                                                       <numIndex index="0">foo</numIndex>
                                                       <numIndex index="1"></numIndex>
                                                   </numIndex>
                                               </items>
                                           </config>
                                       </TCEforms>

Example: Four checkboxes in three columns

TCA:

      'checkbox_12' => [ 
         'exclude' => 1,
         'label' => 'checkbox_12 cols=3',
         'config' => [ 
            'type' => 'check',
            'items' => [ 
               '0' => [ 
                  '0' => 'foo1',
                  '1' => '',
               ],
               '1' => [ 
                  '0' => 'foo2',
                  '1' => '',
               ],
               '2' => [ 
                  '0' => 'foo3',
                  '1' => '',
               ],
               '3' => [ 
                  '0' => 'foo4',
                  '1' => '',
               ],
            ],
            'cols' => '3',
         ],
      ],
      // Example from extension "styleguide", table "tx_styleguide_elements_basic"

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

FlexForm:

                                    </settings.checkbox_2>
                                    <settings.checkbox_12>
                                       <TCEforms>
                                           <label>checkbox_12 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>

Example: Checkboxes with inline floating

      'checkbox_16' => [ 
         'exclude' => 1,
         'label' => 'checkbox_16 cols=inline',
         'config' => [ 
            'type' => 'check',
            'items' => [ 
               '0' => [ 
                  '0' => 'Mo',
                  '1' => '',
               ],
               '1' => [ 
                  '0' => 'Tu',
                  '1' => '',
               ],
               '2' => [ 
                  '0' => 'We',
                  '1' => '',
               ],
               '3' => [ 
                  '0' => 'Th',
                  '1' => '',
               ],
               '4' => [ 
                  '0' => 'Fr',
                  '1' => '',
               ],
               '5' => [ 
                  '0' => 'Sa',
                  '1' => '',
               ],
               '6' => [ 
                  '0' => 'Su',
                  '1' => '',
               ],
            ],
            'cols' => 'inline',
         ],
      ],
      // Example from extension "styleguide", table "tx_styleguide_elements_basic"

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