I created a custom views style plugin. I currently use:

$value = $view->field[$label_column]->getValue($row);

to get the value of the field. However, I was recently informed that this does not work for list fields(like 0=>'yes'=, 1=>'no'). This original line displays 0 and 1 instead of 'yes' and 'no'. This user suggested I use:

$items = $view->field[$label_column]->getItems($row);
$value = $view->field[$label_column]->render_item(1, $items[0]);

It seems like this solution does not work on standard fields. I also recently found that the original line does not respect field rewrites. Is there a universal way to see the field value after rewrites, while also respecting lists?


Use advancedRender(), this is a method in the base class of views fields, which renders an entity field respecting field rewrites and other settings:

$value = $field->advancedRender($row);
| improve this answer | |

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.