3

I am using the flag module to toggle a node type 'Task' as Done. I made a view that lists the tasks, and added a views exposed filter for the flag status, which is a boolean field. In this way users can filter the view by selecting True or False for the flag status.

However, I want to change the labels 'True' and 'False' to 'Done' and 'Not Done'

I see no setting in the views exposed filter field that allows to change this setting. Is there another way to do this?

enter image description here

enter image description here

1 Answer 1

6

There is a number of ways how to do it, check out this thread for a lot of suggested options: Change the '- Any -' text in an exposed taxonomy filter.

You can change the themed output for that form and filter, you need a bit of custom code for that.

You could use Better Exposed Filters module, it lets you override each option text:

Use this field to rewrite the filter options displayed. Use the format of current_text|replacement_text, one replacement per line. For example:

Current|Replacement
On|Yes
Off|No

Without any additional modules or code changes you can use the Flagged Exposed filter Grouped filters option instead of the Single filter you're using now.

The Grouped filters allow you to enter a Label for each grouping. Only in your case you simply select "True" for the first grouping and "False" for the second grouping, which means you haven't grouped anything, you're just repeating the same options from the Single filter:

enter image description here

3
  • The last item here should be the first, as it doesn't require additional contrib or custom modules.
    – colan
    Commented Feb 11, 2020 at 19:37
  • I put it last because it can be seen as a bit of a hack, using Grouped feature without grouping anything.
    – prkos
    Commented Feb 8, 2021 at 15:06
  • Grouped filters is the winner, worked for me Commented Nov 21, 2022 at 17:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.