After #367595: Translatable fields, taxonomy term field autocomplete widgets broke in a big way. The process function for the autocomplete FAPI element doesn't know about language codes. When it's educated about language codes, the validate function does not (cannot?) use form_set_value to translate the typed term names into term IDs.

This patch does NOT fix the problem, but it does get you into the same corner I'm in.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Anonymous’s picture

After #367595: Translatable fields, taxonomy term field autocomplete widgets broke in a big way. The process function for the autocomplete FAPI element doesn't know about language codes. When it's educated about language codes, the validate function does not (cannot?) use form_set_value to translate the typed term names into term IDs.

This should read:

When it's educated about language codes, the validate function does not (cannot?) use the language code when it uses form_set_value to translate the typed term names into term IDs.

and why didn't it add my patch? because it's too early for me to be working the queues. This patch is not a fix, so have a look but don't expect it to solve anything.

plach’s picture

Status: Active » Needs review
FileSize
1.36 KB

The attached patch seems to fix the bug.

plach’s picture

The previous patch was incomplete, I spoke with bangpound and came up with the attached one.

There are a couple of fixes on the Field API and UI: in field_default_form we forgot to pass the $langcode parameter to field_get_default_value (this was not necessary to fix the bug); in field_ui_field_edit_form_submit the patch fixes the default widget to take into account the language key, which is removed as it is not supposed to be there but on a higher level in the data structure.

The patch fixes taxonomy_autocomplete_elements_process which didn't take into account the case in which $element['#value'][$field_key] was defined, thus putting an array into $typed_string. It also fixes taxonomy_autocomplete_validate in order to properly handle the new language level introduced into the field form elements with translatable fields.

Anonymous’s picture

Status: Needs review » Reviewed & tested by the community
webchick’s picture

Status: Reviewed & tested by the community » Fixed

Ok, looks like this is just moving some stuff around after TF. I committed to HEAD.

Please file a critical task to write tests for this area of code so we do not break it again.

Anonymous’s picture

Status: Fixed » Closed (fixed)
Issue tags: -translatable fields

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