Issue when displaying a dropdown list in Symfony

  Kiến thức lập trình

Am using the following code in order to display a dropdown list from a mariadb database table, however it does not work when testing and it :

<?php

namespace AppForm;

use AppEntitySignal;
use SymfonyComponentFormAbstractType;
use SymfonyComponentFormFormBuilderInterface;
use SymfonyComponentOptionsResolverOptionsResolver;
use SymfonyComponentFormExtensionCoreTypeChoiceType;

class SignalType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $builder
            ->add('actionPlan')
            ->add('actionPlanStatus', StatusType::class, [
                'class' => Status::class,
                'mapped' => false,
                'choise_label' => function(Post $post){
                    return $post->getName();
                }
                 ])
            ->add('deadline')
        ;
    }

    public function configureOptions(OptionsResolver $resolver): void
    {
        $resolver->setDefaults([
            'data_class' => Signal::class,
        ]);
    }
}

I get the following error.

An error has occurred resolving the options of the form “AppFormStatusType”: The options “choise_label”, “class” do not exist. Defined options are: “action”, “allow_extra_fields”, “allow_file_upload”, “attr”, “attr_translation_parameters”, “auto_initialize”, “block_name”, “block_prefix”, “by_reference”, “compound”, “constraints”, “csrf_field_name”, “csrf_message”, “csrf_protection”, “csrf_token_id”, “csrf_token_manager”, “data”, “data_class”, “disabled”, “empty_data”, “error_bubbling”, “error_mapping”, “extra_fields_message”, “form_attr”, “getter”, “help”, “help_attr”, “help_html”, “help_translation_parameters”, “inherit_data”, “invalid_message”, “invalid_message_parameters”, “is_empty_callback”, “label”, “label_attr”, “label_format”, “label_html”, “label_translation_parameters”, “mapped”, “method”, “post_max_size_message”, “priority”, “property_path”, “required”, “row_attr”, “setter”, “translation_domain”, “trim”, “upload_max_size_message”, “validation_groups”.

Can you please help me unlocking this situation.

LEAVE A COMMENT