Problem/Motivation

There is currently no way to get raw values from custom fields in the preprocess functions for advanced theming.

Proposed resolution

For custom_field theme function:
Add the following:

#object (the entity object)
#entity_type
#bundle, 
#language
#raw_value (the raw field value)

For custom_field_item theme function:
Add: the following:

#entity_type
#bundle, 
#language
#raw_value (the raw subfield value including extra columns if applicable)

Note: The #raw_value for custom_field_item can be either a scalar or an array depending on whether the subfield type has extra columns.

Command icon Show commands

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

apmsooner created an issue. See original summary.

apmsooner’s picture

Assigned: apmsooner » Unassigned
Status: Active » Needs review
apmsooner’s picture

Issue summary: View changes
apmsooner’s picture

Issue summary: View changes
apmsooner’s picture

Issue summary: View changes
scottsawyer’s picture

Status: Needs review » Reviewed & tested by the community

@apmsooner

This looks great to me. I see all the keys under $variables['elements'] when preprocessing the field, which is fantastic as it will save at least 1 entity load per field instance in my case.

Oh, I could only test on 5.0.x.

apmsooner’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.