[development] Node types in hook_form_alter()

James Benstead james.benstead at gmail.com
Sat Dec 12 20:47:11 UTC 2009


I'm writing a module that adds a field to the create/edit forms for nodes of
certain types - the actual types can be chosen by the user. There are loads
of ways to identify the type of the current node from within
hook_form_alter(), but is there an accepted standard way to do it?

If I use $form['type']['#value'] I get "Notice: Undefined variable" warnings
as my local server's error reporting is very verbose. I know I could change
the error reporting level, but surely it's better practice to try and kill
the bug?

And if I use $form_id I have to use nodetype_node_form and convert it to
nodetype - and, as an aside, I can't find a PHP function to do this cleanly.

So, what's the accepted way to do this?
--
Google Talk/Windows Live Messenger/AIM: james.benstead at gmail.com
Yahoo! Messenger/Twitter/IRC (Freenode): jim0203
Jabber: jim0203 at jabber.org // ICQ: 7088050
Skype: jimbenstead
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20091212/ec926670/attachment.html 


More information about the development mailing list