I have written a custom module where i need to sanitize (replace) filed value of a node being displayed [replacing filed value only while displaying it, and not its original content].

To accomplish this, I thought to implement hook_field ($op = 'sanitize') in my custom module but unfortunately it is not being called by drupal system. I verified it by placing drupal_set_message() at very first line of code withing hook_field(), but no luck. Again when one of module in my project (link-6.x) has hook_field() has been implemented and gets call from drupal system with no issues.

Can any one explain me, either this is a bug or I am missing someting?

Thank you.

Comments

Damien Tournoud’s picture

Project: Drupal core » Content Construction Kit (CCK)
Version: 6.20 » 6.x-3.x-dev
Component: field system » General
Category: task » support

Triaging.

hook_field() is only called for the module defining the field, so this seems by design.

xjm’s picture

Project: Content Construction Kit (CCK) » Drupal core
Version: 6.x-3.x-dev » 6.20
Component: General » field system
Priority: Major » Normal
Status: Active » Closed (works as designed)

The field API was added in Drupal 7. You want hook_nodeapi().

xjm’s picture

Project: Drupal core » Content Construction Kit (CCK)
Version: 6.20 » 6.x-3.x-dev
Component: field system » General
Status: Closed (works as designed) » Active

Whoops, simultaneous responses. :)

ice5nake’s picture

The fact that hook_field() is only called for the module defining the field is not well documented.

I am having the same problem in the module that is defining the field. I am using Features to define the Content Type and the Fields but I am still not seeing a call to hook field. Although I am using 6.x-2.9.