0

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');
}),
Andrew
  • 1
  • 2
  • It is simply impossible (on Symfony and therefore Easyadmin) to render an attribute twice in a form (here `attributeValues`). Why do you want to do this? – vinceAmstoutz Jun 17 '22 at 07:04
  • Hi @vinceAmstoutz ! **AttributeValues** stores the values of all product properties and there can be a very large number of them. For the convenience of creating/editing products, I would like to divide the values into property (**entity.attribute**) categories. – Andrew Jun 17 '22 at 08:23
  • @vinceAmstoutz Javier Eguiluz wrote in his response to Github ([link](https://github.com/EasyCorp/EasyAdminBundle/issues/3751#issuecomment-860900162)) that it is possible to use two absolutely identical fields. Maybe I misunderstood? – Andrew Jun 17 '22 at 08:34
  • At no point in any case does it provide a functional solution. Sorry but for me isn't possible so I can tell you how you can do that. – vinceAmstoutz Jun 21 '22 at 06:23
  • Well done man :) ! – vinceAmstoutz Jun 22 '22 at 11:49

0 Answers0