A little bit of context:

I am running a headless Drupal 8 with React in the front-end. All the data gets exposed through various endpoints.

Now i am trying to render a view in react, there was no problem in obtaining the data. But when i tried to get the exposed filters i ran into a problem (the filters are based on taxonomy terms). I expected to get the filter values like this:

value: {5:"Value one", 6:"Value two", 49:"Value three", 50: "Value four"}

Except i got the filter values like this:

value: {5:5, 6:6, 49:49, 50:50}

So it feels like instead of get the key and value i only get the keys... I am wondering if i am doing something wrong or there is another way of obtaining the exposed filter values.

The following code i am using to obtain the filters

$this->$view // ViewExecutable
$filter = [];
foreach ($this->view->filter as $filer) {
  if($filter->isExposed()) {
    $filters[] = $filter->options;

I think everything is fine. You have to load the taxonomy term names manually like:


Or maybe you can do a custom query to load only the taxonomy term titles without any field data (because that is what you need).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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