API page: https://api.drupal.org/api/drupal/modules%21field%21field.attach.inc/fun...
> Invoke a field hook.
Not very descriptive.
Looking at the code:
$function = $options['default'] ? 'field_default_' . $op : $field['module'] . '_field_' . $op;
This invokes either field_default_HOOKNAME, or FIELDMODULE_field_HOOKNAME, where FIELDMODULE is the module that provides the field's field type (via hook_idontrememberoffhand()).
I am not sure what circumstances determine which of the two is invoked.
It should also be noted that these are not true hooks, they are 'magic callbacks'.
Comments
Comment #1
jhodgdonIt calls field_default_$op if $options['default'] is set to TRUE, and invokes hook_$op on the module defining the field if $options['default'] is omitted or FALSE.
And you are right, the "hooks" are not really hooks, just like the node API hooks are not really hooks, but let's not get into that here.
Anyway, I agree the documentation is a bit lacking. I don't think it's a huge priority to fix it though, since the function starts with _ and is therefore internal-use, and under $options['default'] it does actually tell you what it invokes, even if the first line doesn't.
Comment #2
joachim commentedIt's internal use only, but it's not a black box: I was doing some debugging today to find out why field_attach_validate() wasn't behaving as expected, and to get to your field modules' implementations of the field validate hooks, you have to understand what this function is calling.
Comment #3
jhodgdonI'm not saying we shouldn't fix this documentation. I'm just saying it may not be the highest priority, since if you dig deep enough the docs are there and it is an internal-use function. There are many more serious documentation bugs active, unfortunately.