API page: http://api.drupal.org/api/drupal/modules--node--node.api.php/function/ho...

The documentation says that the hook is on node_example module, and it isn't there.

I'm not sure the hook_node does what the documentation states. I'm under the impression that the hook has a different name: hook_node_form

Cheers,

Comments

jhodgdon’s picture

Title: Documentation problem with hook_form » hook_form doc references example project and shouldn't in D7

You identified two problems here:

a) example reference - You are correct, the node example module for D7 does not include hook_form any more, so that reference should be removed from the documentation.\

b) name of this hook - On this you are incorrect. hook_form() is one hook, and hook_node_form() is a separate hook. See http://api.drupal.org/api/drupal/modules--node--node.pages.inc/function/... to see where hook_form() is invoked, and http://api.drupal.org/api/drupal/modules--node--node.api.php/group/node_... for a complete list of node hooks. I don't think there is a hook_node_form() in D7. I think the doc on the hook_form() page is correct.

So we do need to fix (a).

francort’s picture

Thank you for the information!
When I've implemented node_example_form() , nothing has happened. But when I've implemented node_example_node_form() the form defined on the function took control over the node_example form.
The description on the documentation is more similar to what happened with node_example_node_form thus I though It could be an error on the hook name.

jhodgdon’s picture

I don't know what to tell you. Obviously, it needs some investigation...

barrett’s picture

Assigned: Unassigned » barrett
Status: Active » Needs review
barrett’s picture

attaching the patch this time...

jhodgdon’s picture

Barrett: I think we need a bit of investigation into the above questions - is this really supposed to be hook_form or hook_node_form, and if both exist, why isn't hook_node_form documented anywhere and what does it do?

drewish’s picture

The hook is hook_node_form() so if the name module is example_node then the implementation would be named example_node_node_form().

Update: Actually that's not correct, I was thinking this was a D6 issue and even there it's more complicated.

jhodgdon’s picture

drewish: I think the hook is hook_form() in d7. See #1 above. If the hook really is called hook_node_form() then we have a lot of reworking of doc to do...

damien tournoud’s picture

There is no such thing as hook_node(). What we have is a *callback* (or "pseudo-hook"), named [node type base]_form().

jhodgdon’s picture

Sure. But we call it hook_form(), just like we call all the other pseudo-hooks hook_whatever().

damien tournoud’s picture

I know we do, but we should not.

jhodgdon’s picture

I agree, but we can't really change it now for d6/7. Let's bring that up as a separate issue for D8 coding/doc standards.

barrett’s picture

Assigned: barrett » Unassigned

I'm unassigning myself since I'm not sure what the correct solution is for this issue.

jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

I think we should just commit the patch in #5.

jhodgdon’s picture

Title: hook_form doc references example project and shouldn't in D7 » hook_form doc references example project and shouldn't in D7/8
Version: 7.x-dev » 8.x-dev

Needs to go to d8 and then d7

dries’s picture

Version: 8.x-dev » 7.x-dev

Committed to 8.x.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 7.x. Thanks!

Status: Fixed » Closed (fixed)
Issue tags: -hooks (duplicate)

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