Raw value tokens not replaced if used in css class

Created on 28 August 2011, over 13 years ago
Updated 9 September 2024, 4 months ago

Problem/Motivation

The __value tokens in views don't work for adding classes to fields or rows.

Steps to reproduce

  1. Install Drupal
  2. Add a text/select field to the basic page content type with some values
  3. Add some basic page nodes with values selected
  4. Create a view of basic pages
  5. In the formatting settings, try to add the field value as a class using replacement tokens:

  6. See that the default token works, but the __value token for the raw value does not output anything:

Proposed resolution

Either fix the issue so the raw value can be used, or update the text to indicate the are not supported.

Remaining tasks

  1. Confirm approach
  2. MR with fix or text change
  3. Review
  4. Commit

Original report

If I want to create a class for a field or row or etc. using replacement patterns raw values it won't work. It will just replace if I don't use the raw value.

Example:
- if I enter state-[field_state] it works fine (returning state-In work which anyway isn't css compliant)
- if I enter state-[field_state-value] it just returns state--field_state-value when it should return state-1(or whatever the raw value is)

Shouldn't it work with raw values also? If I use them in "Rewrite results" the raw values are displayed correctly.

A little backtracking on this bug brought me to function tokenize_value($value, $row_index = NULL) in views_handler_field.inc.php. I think this is the function that should replace the token with it's proper value but it doesn't do that. But from there on I'm lost :).

πŸ› Bug report
Status

Needs work

Version

11.0 πŸ”₯

Component
ViewsΒ  β†’

Last updated 24 minutes ago

Created by

πŸ‡·πŸ‡΄Romania Alex Savin

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024