drupal form alter in webform forms
Solution 1
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.
Solution 2
You can do it,
you just need the id of the node and then use the id like in hook_form_<FORMID>_alter()
the FORMID generated is webform_client_form_<NODEID>
where NODEID is the id of the node
so if you have a module named mymodule and a node with id 44 which has a webform
function mymodule_form_webform_client_form_44_alter(&$form, &$form_state) {
// code here;
}
Solution 3
You can use hook_form_alter()
, accessing elements via $form['submitted']
.
Related videos on Youtube
Mamadou
Updated on June 04, 2022Comments
-
Mamadou over 1 year
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? -
Mamadou over 12 yearsI would like to capture data in php and do watever i want with
-
yunzen about 12 yearsNot quite sure about that. I think webforms can be added to any node type.