No, there's no reason it should be for forms only. In fact there's a patch by gordon in the queue that adds both pre_render and post_render optional callbacks for any drupal_render()'able structure. It's a good patch. +1! ;-) http://drupal.org/node/147662 This patch also makes it possible to take full advantage of hook_elements() default properties when building non-form structures that will ultimately be passed through drupal_render(). --Jeff On Jun 16, 2007, at 1:04 PM, Dave Cohen wrote:
Now that the data structures developed for forms are being used for other data structures, particularly nodes, is there any reason why the #pre_render callback is available only in forms?
I suggest moving the code that calls #pre_render callbacks from drupal_render_form() into drupal_render().
In particular I would like to add #pre_render hooks in my hook_view, so that I can tweak the node's content structure before it gets themed. Right now I see no reliable way to do this, short of making a special module with a very heavy weight so that it's nodeapi hooks are guaranteed to be called last.
If there is positive feedback to this suggestion, I will submit patches for drupal-5.x and head. Thanks.
-Dave