Relationship Fields in Filters

Relationship Fields in Filters

emergingdzns -
11 months ago

How do I make the relationship fields in the filters of the table builder display the labels of the options and not the ids?
For example, I have a Category model and a relationship in the module for the CategoryModel. Same for the Type model. Then the $filters array looks like this:

protected $filters = [
'name',
'category',
'type',
];

But when I view it, and pull down the select list, the ids appear. See this screenshot:

emergingdzns -
11 months ago

piterden -
11 months ago

Any relationship fields should show name or title by default. anomaly.field_type.relationship, for example.
Of course for right behavior, they should be setup correct, before that.

As I can see, you want to filter by no-relation field. That means that you need to write some lines of code, to solve your problem.
Please, take a look at the examples:
StatusFilterQuery there /core/anomaly/users-module/src/User/Table/UserTableBuilder.php and /core/anomaly/posts-module/src/Post/Table/PostTableBuilder.php
Then you'd better to investigate how filters are appointed in other modules.
As for me, on you place, I would prefer to write a function in Presenter class of your model (stream).