-
Notifications
You must be signed in to change notification settings - Fork 189
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
How do I display meaningful previews for my models? #246
Comments
hi @preslavrachev |
@raven-chen Everywhere, where a relation is displayed. Say I have an order that has a user. If the user struct has no name attribute, I would get a list of orders, where in the column user, instead of seeing something humanly-readable (e.g. an email, or first namd + last name), I basically see something like the above. The same applies for when attaching a user to an order. I don't see humanly readable identifiers in the dropdowns, but some machine generated concatenation of the struct name and the id (all my model IDs are UUIDs BTW, I have a function that does that upon creation). does that make sense? |
|
Yeah, that's what I did too. If you mark the field as ignored by Gorm, it works, but it's a very obscure way of solving the problem. Relying on an established interface implementation (e.g. |
Agreed that adding a "stringer" as an option for resources would be great! |
This is an undocumented feature, just add the method Stringify() string to your model, with value receiver, cause pointer receiver won't work. It's implemented here: https://github.com/qor/qor/blob/bfbb16ecbc40da17c123aa7cd7211b47caa31391/utils/utils.go#L164 |
I know that the admin tries to make sense of the field names within the struct types and display the ones that make sense. However, it often falls into a situation, where it literally has no clue. Then, we end up having something like:
What would be the preferred way to hint at QOR Admin which fields to use when displaying a preview?
The text was updated successfully, but these errors were encountered: