It is not possible to save some of the values of the language field with entity metadata wrapper, because it throws a validation error.
It affects all the languages that contains a "-"
For example: pt-br
Error message:
Invalid data value given. Be sure it matches the required data type and format. Value at user(1)->field_lang: pt-br. dans EntityMetadataWrapper->set()
The definition of the field is the following:
'property_type' => 'token'
It is the value that entity metadata wrapper takes into account when validating, and with this "token" value the usage of "-" is not allowed.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | 2895585-data-type.patch | 413 bytes | stephaneq |
Comments
Comment #2
johnvCan you give me an example how to test this?
Comment #3
stephaneqHi,
I have the same issue, but only with some languages. I'm still investigating, but I found the field has the "token" type, and according to the documentation (https://www.drupal.org/docs/7/api/entity-api/data-types), it can accept only "A string containing only lowercase letters, numbers, and underscores; e.g. this type is useful for machine readable names."
So my guess is the error occurs when the language has also the country code in its name (for example, fr-be, pt-br etc.), as the dash is not accepted.
Comment #4
johnvOp also states that Token is the root cause. Can you change it to 'text' and test that?
Comment #5
stephaneqI tested, and it works.
I made a patch, but I don't know the other impacts that it may have to change the data type.
Comment #6
stephaneqComment #7
johnvComment #9
johnvThanks,
committed as-is.
Comment #11
czigor commentedThis breaks rules integration again. See #2805191: Rules does not work any more with languagefield tokens.