Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception when accessing nullable object's fields #127

Open
igormukhingmailcom opened this issue Feb 12, 2021 · 1 comment
Open

Exception when accessing nullable object's fields #127

igormukhingmailcom opened this issue Feb 12, 2021 · 1 comment

Comments

@igormukhingmailcom
Copy link

igormukhingmailcom commented Feb 12, 2021

Sylius version affected: 1.7

Description
When trying to display value of customer.email where customer is nullable, getting next exception:

An exception has been thrown during the rendering of a template ("PropertyAccessor requires a graph of objects or arrays to operate on, but it found type "NULL" while trying to traverse path "customer.email" at property "email".").

This is grid configuration:

sylius_grid:
    grids:
        setono_sylius_gift_card_admin_gift_card:
            fields:
                customerEmail:
                    type: string
                    label: setono_sylius_gift_card.ui.customer_email
                    path: customer.email
                    sortable: ~

File where exception throwing: https://github.com/Sylius/SyliusGridBundle/blob/03f8a15ef4d7d83e5e36c9bf4277ca347c925500/src/Component/DataExtractor/PropertyAccessDataExtractor.php

Possible solution
Fallback to empty string or null on exception as shown at:
Setono/SyliusGiftCardPlugin@b8c9347

@damic88
Copy link

damic88 commented Jul 13, 2023

Possible solution @igormukhingmailcom

sylius_grid:
    grids:
        setono_sylius_gift_card_admin_gift_card:
            fields:
                customerEmail:
                    type: string
                    label: setono_sylius_gift_card.ui.customer_email
                    path: customer?.email
                    sortable: ~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants