Home > Mobile >  Problem when using duplicate AssociationField fields of the same EasyAdmin entity
Problem when using duplicate AssociationField fields of the same EasyAdmin entity

Time:06-23

EasyAdmin 4
There is an M2M relationship between Product and AttributeValue.
There can be thousands of rows in AttributeValue, and to make it easier to create/edit products, you need to divide the values by attribute, which is actually done through QueryBuilder, but there is a problem when using duplicate AssociationField ('AttributeValues'). When editing or creating an object, only the (last) "Property #2" field is displayed.
How to fix it?

AssociationField::new('attributeValues', 'Property #1')
->setQueryBuilder(function(QueryBuilder $qb) {
return $qb->andWhere('entity.attribute = 5');
}),

AssociationField::new('attributeValues', 'Property #2')
->setQueryBuilder(function(QueryBuilder $qb){
return $qb->andWhere('entity.attribute = 1');
}),

CodePudding user response:

Solved the problem via JavaScript.

  • Related