Crud EasyAdmin 3 Symfony 5积垢控制器关联字段

Crud EasyAdmin 3 Symfony 5积垢控制器关联字段,crud,symfony5,easyadmin3,Crud,Symfony5,Easyadmin3,我将EasyAmdin 3与Symfony 5一起使用,我在挑战和实现之间有一种单一的关系。在Challenge.php中定义: /** * @ORM\OneToMany(targetEntity=Encadrement::class, mappedBy="challengePartner") */ private $bornes; 我为挑战制作了一个CRUDController,我希望能够在创建/编辑挑战时直接添加封装。我这样做: Associatio

我将EasyAmdin 3与Symfony 5一起使用,我在挑战和实现之间有一种单一的关系。在Challenge.php中定义:

/**
 * @ORM\OneToMany(targetEntity=Encadrement::class, mappedBy="challengePartner")
 */
private $bornes;
我为挑战制作了一个CRUDController,我希望能够在创建/编辑挑战时直接添加封装。我这样做:

        AssociationField::new('bornes'),
我可以在已经创建的所有封装之间进行选择。但我想要的是能够多次添加装箱,我找不到如何做到这一点。我试着制作自己的装箱单类型:

class EncadrementType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('name', TextType::class, array(
                "label" => "Nom"
            ))
            ->add('low', IntegerType::class, array(
                "label" => "Borne basse"
            ))
            ->add('high', IntegerType::class, array(
                "label" => "Borne haute"
            ))
        ;
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults([
            'data_class' => Encadrement::class,
        ]);
    }
}
在《挑战者》中有类似的内容:

        AssociationField::new('bornes')->setFormType(EncadrementType::class),
但是,当我甚至不使用这些选项时,就会出现这个错误:

An error has occurred resolving the options of the form "App\Form\EncadrementType": The options "class", "multiple", "query_builder" 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", "ea_crud_form", "empty_data", "error_bubbling", "error_mapping", "extra_fields_message", "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", "legacy_error_messages", "mapped", "method", "post_max_size_message", "property_path", "required", "row_attr", "setter", "translation_domain", "trim", "upload_max_size_message", "validation_groups".
我尝试将多个选项添加到AssociationField,但没有任何效果:

        AssociationField::new('bornes')->setFormTypeOption("multiple","true"),

我被困在那里了,谢谢你的帮助

像这样尝试CollectionField:

<?php
yield CollectionField::new('bornes')
    ->setFormTypeOptions([
        'delete_empty' => true,
        'by_reference' => false,
    ])
    ->setEntryIsComplex(false)
    ->setCustomOptions([
        'allowAdd' => true,
        'allowDelete' => true,
        'entryType' => EncadrementType::class,
        'showEntryLabel' => false,
    ])
    ;

就是这样,使用CollectionField而不是AssociationField。谢谢