src/Knp/DictionaryBundle/Form/Type/DictionaryType.php
public function configureOptions(OptionsResolver $resolver): void
    {
        $dictionaries = $this->dictionaries;

        $choices = function (Options $options) use ($dictionaries) {
            $name    = $options['name'];
            $choices = $dictionaries[$name]->getValues();

            return array_flip($choices);
        };

        $resolver
            ->setDefault('choices', $choices)
            ->setRequired(['name'])
            ->setAllowedValues('name', array_keys(iterator_to_array($this->dictionaries)));
    }
public function configureOptions(OptionsResolver $resolver): void
    {
        $dictionaries = $this->dictionaries;

        $choices = function (Options $options) use ($dictionaries) {
            $name    = $options['name'];
            $choices = $dictionaries[$name]->getValues();

            return array_flip($choices);
        };

        $resolver
            ->setDefault('choices', $choices)
            ->setRequired(['name'])
            ->setAllowedValues('name', array_keys(iterator_to_array($this->dictionaries)));
    }
{@inheritdoc}