Sylius: Grid filter entity fails

Created on 5 Sep 2016  路  2Comments  路  Source: Sylius/Sylius

I'm trying to create a filter of AdminUser that created an entry on our blog, but when I search something, it shows me an error:

An exception has been thrown during the rendering of a template ("[Semantical Error] line 0, col 67 near 'author.username': Error: 'author' is not defined.") in SyliusAdminBundle:Crud:_grid.html.twig at line 30.

The table shows perfectly:

fields:
    author:
        type: twig
        label: dinamic.ui.author
        options:
            template: DinamicSyliusBlogBundle:Post/Field:author.html.twig

I looked at the Grid of orders to know how search about customers, and i copied it from there. But nothing.

filters:
    author:
        type: string
        label: dinamic.ui.author
        options:
            fields: [author.username, author.email]

Hooking to the Doctrine queries, i found one difference. On my query, doctrine isn't creating a LEFT JOIN relation to get data of my Grid.

Order grid filtering by customer

SELECT count(DISTINCT s0_.id) AS sclr0 FROM sylius_order s0_ LEFT JOIN sylius_customer s1_ ON s0_.customer_id = s1_.id WHERE s0_.completed_at IS NOT NULL AND (s1_.email LIKE '%Osv%' OR s1_.first_name LIKE '%Osv%' OR s1_.last_name LIKE '%Osv%')

Post grid filtering by author (AdminUser)

SELECT o FROM App\Bundle\SyliusBlogBundle\Entity\Post o WHERE (author.username LIKE '%Osv%' OR author.email LIKE '%Osv%') AND o.published = :published ORDER BY o.createdAt desc

Help Wanted

All 2 comments

Yeah, thanks a lot @Raptek I didn't see that 馃憤

Works perfectly!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

loic425 picture loic425  路  3Comments

mikemix picture mikemix  路  3Comments

igormukhingmailcom picture igormukhingmailcom  路  3Comments

javiereguiluz picture javiereguiluz  路  3Comments

stefandoorn picture stefandoorn  路  3Comments