Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
documentation
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
1 Dec 2010 at 02:09 UTC
Updated:
16 Dec 2010 at 00:20 UTC
Jump to comment: Most recent file
In hook_field_validate(), the errors array is described as:
$errors[$field['field_name']][$delta][]
instead of:
$errors[$field['field_name']][$langcode][$delta][]
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 985804-hook-field-validate-1.patch | 1.86 KB | solotandem |
| #1 | 985804-hook-field-validate.patch | 1.43 KB | solotandem |
Comments
Comment #1
solotandem commentedA 2-line patch is attached.
Comment #2
solotandem commentedThis was the title originally input, but after preview the default title from api.d.o was back.
Comment #3
jhodgdonGood catch! I see that this issue report is correct (you can look at text_field_validate() for a working example).
One small thing:
I don't think we should use "langcode" in documentation text. It should be "language code", I think. And I'm not sure about value delta -> delta -- did you do that on purpose or just to make the line wrap at the same spot? What's the usage elsewhere in the field API?
I like the parens you added to the documentation though -- good decision.
Comment #4
solotandem commentedAs is often the case, the usage varies as the summary below confirms. Given that, how about we use the word "language" instead of "langcode" in the item you question above?
In hook_field_attach_view_alter(), one of the keys is "language: The language code used for rendering."
In hook_field_attach_prepare_translation_alter(), one of the keys is "langcode: The language the entity has to be translated in."
In hook_field_language_alter(), one of the keys is "langcode: The language code $entity has to be displayed in."
In hook_field_load(), $langcode is described as "The language code associated with $items." In all (or virtually all) other instances, $langcode is described as "The language associated [with|to] $items" or "The language the field values are to be [entered|shown] in. If no language is provided the [current|default site] language is used."
In hook_field_widget_form(), one of the $element keys is "#language: The language the field is being edited in." Is this the language code or the language object?
This is in addition to the differences in the variable names in the code.
Comment #5
jhodgdonThe examples you are giving for language vs. langcode vs. language code are where the literal 'langcode' or 'language' is used as an array key, or where it's a variable name $language or $langcode. Here, neither of those is the case -- it's the two-letter language code that is being used as the array key, and I'm just asking that in the documentation text, we don't use "langcode", which isn't an English word, but instead use "language code" to refer to this two-letter (usually) code.
And it's too bad the other field API hooks are inconsistent about the literal array keys and variable names, but at this point we cannot change the API (too close to release).
The other thing I think we should check for documentation consistency is whether the 3rd key should be referred to as "delta" or "element delta". You changed it in your patch from what it was (element delta) to just "delta", and I am not sure what the justification is for that change, which is why I asked about how it was referred to elsewhere in the documentation.
Comment #6
solotandem commentedRevised patch attached.
Comment #7
jhodgdonThat is fine... do you also want to fix up the line above your changed section?
Should have [] not {} I think?
Comment #8
jhodgdonsolotandem pointed out (gently) in IRC that that is actually the correct notation. So this is fine.
Comment #9
webchickCommitted to HEAD. Thanks!