EasyAdminBundle icon indicating copy to clipboard operation
EasyAdminBundle copied to clipboard

Update FieldFactory.php

Open Meithal opened this issue 3 years ago • 0 comments

Hi,

If you have a doctrine entity such as

#[ORM\Entity(repositoryClass: ProductRepository::class)]
class Product
{
    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column(type: 'integer')]
    private $id;

    #[ORM\Column(type: 'uuid')]
    private UuidV6 $uuid;
    ...

If one of the fields is a "uuid" type, FieldFactory wont recognize it.

If you make a ea crud for such an entity you will get a crash when you will try to edit it with error The Doctrine type of the "uuid" field is "uuid", which is not supported by EasyAdmin. For Doctrine's Custom Mapping Types have a look at EasyAdmin's field docs. error.

My fix is surely not the most proper way to do this but works for me.

Meithal avatar Aug 08 '22 19:08 Meithal

@Meithal we've just merged a related PR (#5356). Could you please check if that's enough to solve the problem that this PR is solving? Thanks.

javiereguiluz avatar Aug 10 '22 17:08 javiereguiluz

The commit looks like it will fix the issue yes, I'll wait for it to get it tagged to confirm.

Meithal avatar Aug 12 '22 20:08 Meithal

@Meithal I checked it and https://github.com/EasyCorp/EasyAdminBundle/pull/5356 does not replace this PR.

But IMHO the error message is correct (The Doctrine type of the "uuid" field is "uuid", which is not supported by EasyAdmin.) and there is no bug. You have to implement ProductCrudController::configureFields() and use TextField::new('uuid').

Your PR should not be merged IMHO because it could produce errors for others. Everybody can implement a custom Doctrine type which is named uuid but we shouldn't guess if the dev wants to use an IdField or an TextField or something else for it. (If we would still guess then we could guess for a lot of other custom Doctrine types as well, which leads to maintain all these custom Doctrine type mappings and discussions about it).

I'm closing this PR but please let me know if you have other thoughts.

michaelKaefer avatar Aug 13 '22 14:08 michaelKaefer