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?
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.
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;
}
You can use hook_form_alter()
, accessing elements via $form['submitted']
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With