I have a entity with two text fields- one of type "text" and the second of type "text_with_summary". Unfortunately I'm not able to set/get the fields values with entity_metadata_wrapper. See post #2 for updated information.

Any help would be very appreciated, thanks!

Comments

haggins’s picture

Issue summary: View changes

Additional information

haggins’s picture

Issue summary: View changes

Updated issue summary.

haggins’s picture

Issue summary: View changes

Updated issue summary.

haggins’s picture

Title: entity_metadata_wrapper forces me to use language code » Cannot modify text fields with entity_metadata_wrapper

I'm getting closer to the problem:

This does not work:

$wrapper->field_text_summary->set(array('value' => 'A description'));

This does:

$wrapper->language('de')->field_text_summary->set(array('value' => 'A description'));

// but NOT:
$wrapper->language('und')->field_text_summary->set(array('value' => 'A description'));

Also, when I try to access the fields data, I'm forced to tell the language:

$wrapper->field_text_summary->value(); // empty!
$wrapper->language('de')->field_text_summary->value(); // gives me the value

What's going on here? Do you need more information?

haggins’s picture

Title: Cannot modify text fields with entity_metadata_wrapper » entity_metadata_wrapper forces me to use language code
Component: Code - misc » Entity property wrapper
haggins’s picture

Issue summary: View changes

Updated issue summary.

haggins’s picture

Title: Cannot modify text fields with entity_metadata_wrapper » entity_metadata_wrapper forces me to use language code on translatable fields
Category: support » bug

The behavior seems to come from the translatable property of a field. If I set a field to non-translatable it works as intended. On translatable fields you are forced to define a language code to work on.

So I mark this as bug since the language should be LANGUAGE_NONE if not explicitly declared.

kle’s picture

this must be a bug, I wonder I didn't recognized this before.
Workaround 2: use of field_get_items() returns the correct language.

kle’s picture

Issue summary: View changes

Updated issue summary.

DamienMcKenna’s picture

You might try the patch in #2335885: 'langcode' option in info array is not applied to see if it helps.