0

In a form, I'm trying to display an items list for the connected user using a2lix. When I try the code bellow, I get error.

Error message

Could not parse property path "translations[en].". Unexpected token "." at position 16

Part of build form

->add('artwork','a2lix_translatedEntity',array('class'=>'CTCArtworkBundle:Artwork',
'query_builder' => function (EntityRepository $er) {
                    return $er->createQueryBuilder('a')
                              ->where('a.UserID = :userID')
                              ->setParameter('userID',$this->user)
                              ->orderBy('a.title', 'ASC');
                    },
'multiple'=>false,
'expanded'=>false,
'empty_value' => 'Choose an artwork',))

I red this a2lixdoc to make my querybuilder but it's not working and this "Using a custom query for entities"

Any advice would help me.

Benjamin Lucas
  • 370
  • 5
  • 20

1 Answers1

0

This code works fine for me.

I read again the a2lix documentation and I saw that I need to use 'translation_property' => 'title', instead of 'property' => 'title'.

array('class'=>'CTCArtworkBundle:Artwork',
      'translation_property' => 'title',
      'query_builder' => function (EntityRepository $er) {
                                        return $er->createQueryBuilder('a')
                                                  ->where('a.user = :userID')
                                                  ->setParameter('userID',$this->user);
                                        },
      'multiple'=>false,
      'expanded'=>false,
      'empty_value' => 'Choose an artwork',))
Benjamin Lucas
  • 370
  • 5
  • 20