This is classic select dropdown that is added like this:

<?php
$this->add('languages', 'select', [
    'choices' => ['en' => 'English', 'fr' => 'French'],
    'selected' => 'en',
    'empty_value' => '=== Select language ==='
]);

Beside inherited it have 3 additional options:

  1. choices (Array) (Default: []) - key value pairs used for options in the select
  2. empty_value (String) (Default: null) - If provided, added to the start of select as empty value
  3. selected (String Array Closure) (Default: null) - Option that needs to be selected. If not provided, Form class will try to fetch it from passed model.
    • array is used when ‘multiple’ attribute is set
    • Closure is used for modifying model data before passed to view. Useful when fetching relationship data to pluck only data that is needed.
<?php
$this->add('languages', 'select', [
    'choices' => ['en' => 'English', 'fr' => 'French'],
    'selected' => function ($data) {
        // Returns the array of short names from model relationship data
        return array_pluck($data, 'short_lang_name');
    }
    'empty_value' => '=== Select language ==='
])