EasyCorp / EasyAdminBundle

EasyAdmin is a fast, beautiful and modern admin generator for Symfony applications.
MIT License
4.08k stars 1.02k forks source link

[3.2] CollectionField broken when using entryType with a form #4302

Open pkly opened 3 years ago

pkly commented 3 years ago

Describe the bug When using a CollectionField with a custom data_class and FormType (extending from AbstractType) the whole look of the form is broken by default, the delete button does not appear. The "complex" style is also not respected and overall looks bad.

To Reproduce Create an entity Foo and entity Bar, add ManyToOne connection, then display the main entity (containing the collection of the other one) as a form (crud) with the following config

        // in configureFields
        yield CollectionField::new('translations')
            ->setEntryType(GenericTranslationType::class) // or other form you created, just map a single field like name, it'll work
            ->setEntryIsComplex(true)
            ->setFormTypeOption('by_reference', false)
            ->setFormTypeOption('entry_options', [
                'data_class' => LanguageTranslation::class, // if your form doesn't actually specify it, otherwise skip
            ]);

(OPTIONAL) Additional context screenshot EeasyAdminBundle 3.2.8, Symfony 4.4

It appears that people are also having an issue when it comes to any fields that aren't text in collections when it comes to deleting and sometimes css.

excitedbox commented 3 years ago

I just had a mismatch problem because class names were not being converted to upper case in the relations code but the file names and classes do.

pkly commented 3 years ago

I just had a mismatch problem because class names were not being converted to upper case in the relations code but the file names and classes do.

@excitedbox Can you explain in more detail?

excitedbox commented 3 years ago

I used the maker bundle to create some entities and then used the make:admin:crud command to create the crud. When I tested them in the browser I was getting the mismatch error with the hints that some class names were lowercase. Then looking at the code "targetEntity=Approvals::class, inversedBy="courses")" Approvals was lower case.

The crud action forms are missing some fields as well, so I need to see if there are other things that need to be capitalized. Or if there is another reason for it.

pkly commented 3 years ago

So you had a mapping problem, I only created the first class with the maker since I extended the abstract class to add some missing functionality and everything is imported class names so this is not an issue here.