drupal form alter in webform forms

Mamadou picture Mamadou · Feb 24, 2011 · Viewed 18.8k times · Source

I know that there is possible to use some functions to alter drupal core forms: hook_form_alter(). Can we use this with Drupal forms that are created with the Webform module?

Answer

alexkb picture alexkb · Oct 2, 2012

In Drupal 7, you can either use hook_form_alter() or hook_form_<formid>_alter(), which ever you prefer. Just make sure you get the naming and parameters right. Drupal 6 only supports hook_form_alter() however.

When you create these functions, also remember that Drupal may not always pick up on them until you've flushed the cache.

Another important thing to note is that if you want to make changes to the webform fields, you have to make changes in $form['submitted']. I made the mistake of originally trying to edit $form['#node']->webform['components'], which has no effect.

More information can be found here: http://drupal.org/node/1558246

Hope that can help.