Closed (fixed)
Project:
Custom Field
Version:
4.0.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
10 Jan 2026 at 12:29 UTC
Updated:
6 Feb 2026 at 18:39 UTC
Jump to comment: Most recent
When a numeric (integer) subfield is retrieved in Twig via Custom Replacement of the same field in a view, there are 2 problems:
Create a custom field X and a subfield Y that is an integer with permitted values 0 and 1 with corresponding labels.
Create a view, add Y, set the format to Label, and in the custom replacement of Y retrieve the Y via Twig:
-) the key is shown and not the label
-) when Y = 1 => "1" is displayed (ok)
-) when Y = 0 => "" is displayed (wrong, empty string)
n/a
n/a
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
apmsooner commentedHi, thanks for the report. I'm able to reproduce and realize there are some revisions overall that need to be made to how views tokens work for custom fields. I will work on a patch and request your review when ready. Thank you.
Comment #3
apmsooner commentedComment #5
apmsooner commented@giuse69,
This is ready to test. See bullets in the Proposed resolution. I've addressed your bug in multiple ways because now the default token you were using will use the rendered value and you'll notice there is a supplemental __raw version of the token if you want to output the stored value in the db.
Comment #6
giuse69 commentedHi @apmsooner, seems ok to me: I tested succesfully all bullets of the proposed solution except the third for map.
You're great!
Comment #7
apmsooner commented