This issue is a side-effect of #367595: Translatable fields. When we added translatable fields, we started passing $langcode into all the field-level hooks. However I discovered that we're not passing this into any of the widget-level hooks. In the case of hook_widget(), this poses a serious problem.

In file.module, we need access to the current value of the field from $form_state['values']. Previously we were using:

  if (isset($form_state['values'][$field_name])) {
    $items = $form_state['values'][$field_name];
  }

However $form_state['values'][$field_name] no longer contains the needed items, it's in $form_state['values'][$field_name][$langcode]. However, $langcode is not known and should be passed into this hook.

This functionality will be needed in any field that contains AJAX behaviors, when the field value needs to be determined entirely by the values for $form_state['values'].

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Status: Needs review » Needs work

The last submitted patch failed testing.

quicksketch’s picture

Status: Needs work » Needs review
FileSize
3.22 KB

Geez core is moving quickly these days. Removed a conflict with the fixed #557932: Taxonomy term field autocomplete widgets never validate, always lose values..

Status: Needs review » Needs work

The last submitted patch failed testing.

sun’s picture

plach’s picture

I agree with quicksketch, this is needed. I made some improvement to the previous patch (fixing some tests and the taxonomy.module).
IMO if the patch passes the tests it's RTBC.

plach’s picture

Status: Needs work » Needs review
plach’s picture

Issue tags: +translatable fields

Status: Needs review » Needs work

The last submitted patch failed testing.

plach’s picture

Status: Needs work » Reviewed & tested by the community

Head was broken. Re-testing.

catch’s picture

Priority: Normal » Critical

Straightforward patch, blocking filefield makes this critical.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Good catch. Committed to HEAD. Thanks!

plach’s picture

Priority: Critical » Minor
Status: Fixed » Reviewed & tested by the community
FileSize
683 bytes

sorry, I missed a comment

yched’s picture

re #12: well, actually it's that whole phpdoc for field_test_field_widget() that should go away, just leaving "Implement hook_field_widget().". hooks are documented in field.api.php, leaving docs in other places is bound to become stale.

plach’s picture

Status: Reviewed & tested by the community » Fixed

Ok, let's open a new issue then: #561150: Clean up field_test.module phpdocs

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

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