Ashwin
Ashwin

Reputation: 460

Inaccessible value for foreign key in easyadmin listing (Symfony 2.8)

I have used easyadmin bundle in my Symfony application. I have user and role entity. I have used role id as an foreign key for user. I am showing user listing in admin section using easy admin.

But for role it show me "Inaccessible" as an value in listing.

If anyone knows how to show actual value for instead of "Inaccessible" then please help me.

Thank you.

Upvotes: 2

Views: 2517

Answers (1)

Javier Eguiluz
Javier Eguiluz

Reputation: 4107

The inaccessible label is displayed when we cannot access to the value of the given property. We use the PropertyPath Symfony component to get property values. This component tries to get the value using several techniques: via public properties (role in your case), via getters (getRole()), issers (isRole()), etc. Please check that the value of the role property can be obtained somehow from outside the entity.

Related to this, and just in case you haven't done it yet, it's a good idea to also define the __toString() magic method in the entities used in relations (Role entity in this case).

Upvotes: 7

Related Questions