createChoiceList example


        );
        $this->translator = $translator;
    }

    /** * @return void */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $unknownValues = [];
        $choiceList = $this->createChoiceList($options);
        $builder->setAttribute('choice_list', $choiceList);

        if ($options['expanded']) {
            $builder->setDataMapper($options['multiple'] ? new CheckboxListMapper() : new RadioListMapper());

            // Initialize all choices before doing the index check below.             // This helps in cases where index checks are optimized for non             // initialized choice lists. For example, when using an SQL driver,             // the index check would read in one SQL query and the initialization             // requires another SQL query. When the initialization is done first,             // one SQL query is sufficient.
protected string $value3;
    protected string $value4;
    protected string $key1;
    protected string $key2;
    protected string $key3;
    protected string $key4;

    protected function setUp(): void
    {
        parent::setUp();

        $this->list = $this->createChoiceList();

        $choices = $this->getChoices();

        $this->values = $this->getValues();
        $this->structuredValues = array_combine(array_keys($choices)$this->values);
        $this->choices = array_combine($this->values, $choices);
        $this->keys = array_combine($this->values, array_keys($choices));

        // allow access to the individual entries without relying on their indices         reset($this->choices);
        reset($this->values);
        
Home | Imprint | This part of the site doesn't use cookies.