Choice field is hybrid type, because it can be:

  • Regular select
  • Select with multiple choices
  • List of radio buttons
  • List of checkboxes
<?php
// This creates list of checkboxes
$this->add('languages', 'choice', [
    'choices' => ['en' => 'English', 'fr' => 'French'],
    'choice_options' => [
        'wrapper' => ['class' => 'choice-wrapper'],
        'label_attr' => ['class' => 'label-class'],
    ],
    'selected' => ['en', 'fr'],
    'expanded' => true,
    'multiple' => true
]);

Beside inherited, there are some additional options available:

  1. choices (Array) (Default: []) - key value pairs that will be used in the list
  2. choice_options (Array) (Default: ['wrapper' => false]) - Options that will be provided to each choice entry
  3. selected (String|Array|Closure) (Default: null) - Item that needs to be selected/checked, if not provided fetched from Model
  4. expanded (Boolean) (Default: false) - If true, list will be of type radios or checkboxes(depending on multiple option)
  5. multiple (Boolean) (Default: false) - If true, allows multiple select or list of checkboxes (depending on expanded option)
expanded multiple Field type
false false Select
false true Select with multiple attribute
true false List of radio buttons
true true List of checkboxes

selected can be modified with Closure the same way like in Select field type