There has been a discussion on the developer mailing list about the inconsistency of the way modules are using various widget and field hooks. I decided to document the hooks that are called and their order (see http://drupal.org/node/82661#comment-162615) and one thing that immediately popped out is that the 'process form values' operation for the widget is getting invoked twice, and another is that the number of times that hooks are being called could probably be reduced with no loss in functionality. The 'submit' operation for the widget is not being used by any modules now, and it's hard to see why it is needed. The 'validate' operation for the widget should (as Ber pointed out on the developers email list) probably be called only by the field rather than by both the field and the widget. The widget needs to be able to massage the returned data back into the format that will be stored in the database, which it can do with 'process form values', then that value can be validated by the field. There are a few modules that have validate called by the widget, but in every case I saw it could just as easily be called by the field. The date module (yes I'm the guilty party) has the widget doing validation in 'process form values' but that dates back to an earlier version of cck which wasn't storing the processed value so that the field could do the validation, and that could be fixed now.

This proposed patch to the content module would eliminate several hooks, but would require affected modules to quit doing validation in the widget to keep from breaking when this is committed (a change they could make at any time). Two of the guilty modules are the userreference and nodereference modules, so they need to be patched, too.

CommentFileSizeAuthor
content.module_12.patch938 byteskarens

Comments

moshe weitzman’s picture

thanks for the docs ... simplification is good.

moshe weitzman’s picture

hook_submit and nodeapi(submit) are in core and in use by some modules. they are a lot like 'prepare the node for saving since it has been validated and will proceed'. i bet they exist in cck just to match core, which is a decent idea since we want all this in core one day anyway.

karens’s picture

Status: Active » Fixed

This has effectively been done in the D6 version -- the widgets use FAPI processing, not custom content handling.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.