Translated default field values are sanitized by i18n_field_translate_default(), which is the translate callback used for fields of type 'text'. However, the normal widget for text fields ('text_textfield') places the value in an input HTML element, where the value should not be sanitized.
Unfortunately, this does sort of reveal a weakness in the way translate callbacks are defined - they should really be per field WIDGET, not field TYPE. Anyway, rather than fully opening that can of worms, I'll just suggest for now that since the only widget for text fields (at least in core) is one that should not have its default value sanitized, this should be (not) done for all 'text' field types. Potentially, we could either do this OR check the widget in use (since the callback gets passed the instance settings which contain the widget to be used) so that other widgets could remain sanitized just in case - i.e. defaulting to sanitizing for the cases that we don't know about. See the attached patch.
Comment | File | Size | Author |
---|---|---|---|
i18n-field-sanitized-textfield-defaults.patch | 904 bytes | james.williams |
Comments
Comment #1
ptmkenny CreditAttribution: ptmkenny commentedComment #2
bgm CreditAttribution: bgm commentedI also ran into this issue, and the patch fixed the problem. Thanks!
Comment #4
Jose Reyero CreditAttribution: Jose Reyero commented@james.williams,
Right
Anyway, not really time for that, and this fixes the issue so committed, thanks,