Problem/Motivation

Before http://cgit.drupalcode.org/languagefield/commit/?h=7.x-1.x&id=611eede097... the language code was available from an wrapped entity object the following way:

$langcode = $wrapped_node->field_language->value->value();

Now it's

$langcode = $wrapped_node->field_language->value();

This however makes languagefields pretty much unusable in rules selectors.

Proposed resolution

Remaining tasks

Fixing it so that [node:field-language] tokens still work afterwards.

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
#2 languagefield-2805191-2-rules.patch5.93 KBczigor

Comments

czigor created an issue. See original summary.

czigor’s picture

Status: Active » Needs review
StatusFileSize
new5.93 KB

I looked at email, link, country, address and commerce_line_item modules on how they support both tokens and entity properties for custom fields. What I learnt is that for a simple, one-column field providing a simple data type like language_field, the hook_field_info() does not need a 'property_callbacks' attribute. Instead, it needs to set a proper 'property_type' attribute (still in hook_field_info()) and implement hook_token_info() and hook_tokens().

The result is that token [node:field_language] yields "English", [node:field_language:value] and $wrapped_node->field_language->value() yield 'en'. What's more, $wrapped_node->field_language has a 'token' property type, which enables us to carry on using it with Rules. Everyone happy.

  • johnv committed 092e5ee on 7.x-1.x authored by czigor
    Issue #2805191 by czigor: Rules does not work any more
    
johnv’s picture

Version: 7.x-1.x-dev » 7.x-1.4
Status: Needs review » Fixed
johnv’s picture

Title: Rules does not work any more » Rules does not work any more with languagefield tokens

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.