7

I have implemented the hook_field_load() and hook_field_formatter_view() function to replace some characters in a specific field's value. But they don't seem to be called at all. I wrote some command like exit() and print_r($field) in the hooks but nothing happens.

When this hooks are called? (and is this the correct way to do alter field values for view?)

5

hook_field_load() and hook_field_formatter_view() aren't hooks really. They rather are callbacks which only can be used from a module implementing the field in question by itself. The documentation at api.drupal.org for both hooks is not very clear in that by stating nothing or just a vague:

Define custom load behavior for this module's field types.

When grepping through the Drupal 7 code you never see this so called hooks invoked by module_invoke_all() which is a clear sign for that functions are not handled like hooks.

hook_field_attach_load() may be used instead of hook_field_load() which is a real hook.

See also the discussion at http://drupal.org/node/702586 for that matter.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.