A new module ‘foo’ implements foo_node_info() where one or more new content types can be defined.
If foo_node_info() defines two content types, namely a content type ‘footypea’ and a content type ‘footypeb’, how does one go about implementing hook_form() (what should the name of the “hook” be?) to configure each node’s editing form?
In the drupal example, the name of the new content type is the same as the module name. What happens in the above described example where two new content types are defined by the module?
Should the implemented hook_form() function be of the form: footypea_form() and footypeb_form() ? (this doesn’t seem to work)
Or should you implement a single foo_form() function and within this create and return an array $form with elements $form[‘footypea’] and $form[‘footypeb’] that are in turn arrays of the individual form field definitions?
In your module’s hook_node_info(), add the
'module'property (see http://api.drupal.org/api/function/hook_node_info/6).For example:
Now you can add the following hook_form() implementations for each type (see http://api.drupal.org/api/function/hook_form/6).
The trick here is that the module property of each element in
hook_node_info()does not have to be the same as the module implementinghook_node_info(). Each type defined can have a unique module property for implementing type specific hooks.