LexikFormFilterBundle icon indicating copy to clipboard operation
LexikFormFilterBundle copied to clipboard

Filter by entity with string id

Open vlastv opened this issue 3 years ago • 3 comments

Error in https://github.com/lexik/LexikFormFilterBundle/blob/master/Event/Subscriber/DoctrineORMSubscriber.php#L111

vlastv avatar Apr 12 '22 09:04 vlastv

?

gilles-g avatar Apr 12 '22 11:04 gilles-g

DoctrineORMSubscriber builds the condition assuming that the primary key is always a integer. But it's not. When the primary key is a string, the filter specifies the type, just like a integer. The code that does this is listed at the beginning.

vlastv avatar Apr 12 '22 13:04 vlastv

A quick solution, as for many other problems with the EntityFilterType, could be to use the ChoiceFilterType instead with a its choices loaded by a Repository method of the Entity in question and maybe also a n additional "none" choice like I described in #293 . But I also see the problem with the fixed INTEGER-type in DoctrineORMSubscriber, that makes the EntityFilterType incompatible with Uuid and other non-integer primary keys.

spackmat avatar Feb 01 '23 10:02 spackmat