Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 517 Vote(s) - 3.48 Average
  • 1
  • 2
  • 3
  • 4
  • 5
drupal form alter in webform forms

#1
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?
Reply

#2
I am not quite sure what you are trying to do, but since webform module creates a content type - webform - you can alter forms created by webform purely through the admin interface - add new inputs and input types, specify whether they are required or not etc.

for example, a "contact us" form can have whatever inputs you want - unlike the core Drupal contact form which IIRC only has an email address and a textarea.
Reply

#3
Yes, if for some reason you need to make a change to the webform which you can't do by editing the webform node, then you can use hook_form_alter to change the form as well, as the webform is created by the form api.

That said, do poke around in some of the corners of webform - it comes with a number of options for dynamically filling or changing parts of the form already.
Reply

#4
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;
}
Reply

#5
You can use `hook_form_alter()`, accessing elements via `$form['submitted']`.
Reply

#6
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:

[To see links please register here]


Hope that can help.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through