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'].
Comment | File | Size | Author |
---|---|---|---|
#12 | field_widget_langcode-559506-12.patch | 683 bytes | plach |
#5 | field_widget_langcode-559506-5.patch | 7.11 KB | plach |
#2 | field_widget_langcode.patch | 3.22 KB | quicksketch |
field_widget_langcode.patch | 3.54 KB | quicksketch | |
Comments
Comment #2
quicksketchGeez core is moving quickly these days. Removed a conflict with the fixed #557932: Taxonomy term field autocomplete widgets never validate, always lose values..
Comment #4
sunsubscribing
Comment #5
plachI 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.
Comment #6
plachOn my box tests are failing due to #559486-4: Test bot doesn't always run all field attach tests.
Comment #7
plachComment #9
plachHead was broken. Re-testing.
Comment #10
catchStraightforward patch, blocking filefield makes this critical.
Comment #11
webchickGood catch. Committed to HEAD. Thanks!
Comment #12
plachsorry, I missed a comment
Comment #13
yched CreditAttribution: yched commentedre #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.
Comment #14
plachOk, let's open a new issue then: #561150: Clean up field_test.module phpdocs