API page: https://api.drupal.org/api/drupal/modules!field!field.api.php/function/h...
Enter a descriptive title (above) relating to function hook_field_schema, then describe the problem you have found:
hook_field_schema() is not a true hook, but a magic callback. It is called ONLY for the module that defines a field type, to get the schema for a field of that type.
The flow in field_create_field() is:
- oh you want a new field do you?
- what type is it?
- which module defines the field type?
- call MODULE_field_schema() to get the schema for your new field.
Comment | File | Size | Author |
---|---|---|---|
#15 | drupal_hook-field-schema-doc-2109957-15.patch | 701 bytes | ar-jan |
#9 | drupal_hook-field-schema-doc-2109957-9.patch | 628 bytes | ar-jan |
#7 | drupal_hook-field-schema-doc-2109957-7.patch | 538 bytes | ar-jan |
Comments
Comment #1
jhodgdonWe have a lot of "hooks" like that. It just needs a sentence stating this.
Comment #2
joachim CreditAttribution: joachim commentedYup. something like:
This is invoked for a specific module by Field API, in order to obtain the database schema when creating a field.
Comment #3
jhodgdon"a specific module" is not very specific. :) How about "on the module that defines the field"?
Comment #4
joachim CreditAttribution: joachim commented"that defines the field type"
Which is a bit messy, as the sentence is referring ahead. But I'm sure some novice will be able to reword it more elegantly; the gist is there :)
Comment #5
ar-jan CreditAttribution: ar-jan commentedHow about
This is invoked when a field is created, in order to obtain the database schema from the module that defines the field's type.
?Or maybe something like
This is implemented by modules defining a field type, and is invoked when creating a field of that type in order to obtain the database schema.
Comment #6
jhodgdonSure, either one sounds fine to me. They both seem to get the point across clearly.
Comment #7
ar-jan CreditAttribution: ar-jan commentedI notice the docs say all-caps should only be used for constants. Should 'MUST' in the line below be changed now that we're looking at this?
Comment #8
jhodgdonYeah, that wouldn't hurt.
Comment #9
ar-jan CreditAttribution: ar-jan commented.
Comment #10
joachim CreditAttribution: joachim commentedLooks perfect to me.
Comment #11
jhodgdonIf we're updating this line, would it make better sense to say "in your module.install file" rather than just ".install"?
Comment #12
jhodgdonComment #13
joachim CreditAttribution: joachim commentedDoesn't look like there's much consistency for this. In system.api.php alone:
modules/system/system.api.php
2996: * must reside in a module_name.install file, or it will not properly abort
3095: * hook_schema() which must live in your module's .install file.
3273: * .install file. The implementation can rely on the .module file being loaded.
3347: * Implementations of this hook should be placed in a mymodule.install file in
3445: * Implementations of this hook should be placed in a mymodule.install file in
3485: * If you remove some update functions from your mymodule.install file, you
3489: * Implementations of this hook should be placed in a mymodule.install file in
3514: * The uninstall hook must be implemented in the module's .install file. It
3540: * implemented in the module's .install file. The implementation can
3555: * implemented in the module's .install file. The implementation can rely
Comment #14
jhodgdonMost of them either say "module's .install file" or "mymodule.install". Saying just " * This hook must be defined in .install " is less clear than either, IMO. Pick one. :)
Comment #15
ar-jan CreditAttribution: ar-jan commentedAlright, let's go with "the module's .install file".
Comment #16
jhodgdonThanks! Looks good.
Comment #17
jhodgdonThanks again! Committed to 7.x.