Drupal form changes in webform forms

I know that you can use some functions to change the forms of the drupal kernel: hook_form_alter() . Can we use this with the Drupal formats that are created using the Webform module?

+6
drupal drupal-webform
source share
5 answers

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

When you create these functions, remember also that Drupal may not always type them until you clear the cache.

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

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

Hope this helps.

+14
source share

You can do it,

you just need the node id and then use the id like in hook_form_ <FormID> _alter ()

generated FORMID: webform_client_form_ <NODEID>

where NODEID is the node identifier

so if you have a module called mymodule and node with id 44 that has a web form

 function mymodule_form_webform_client_form_44_alter(&$form, &$form_state) { // code here; } 
+6
source share

You can use hook_form_alter() , accessing elements through $form['submitted'] .

+2
source share

I'm not quite sure what you are trying to do, but since the webform module creates a content type - a web form - you can change the forms created by webform exclusively through the admin interface - add new inputs and input types, indicate whether they are required or not, etc.

for example, the "contact us" form can have any inputs you need - unlike the basic Drupal contact form, which has only an email address and a text box.

0
source share

Yes, if for some reason you need to make changes to a web form that you cannot do by editing the webform node, you can use hook_form_alter to change the form, since the web form is created by the api form.

This suggests that they are scraped off at some corners of the web form - it has a number of options for dynamically filling in or changing parts of the form.

0
source share

All Articles