Hello.
I use Webform with drupal,
i wanna have a field in all of my webforms, automatically, that will have some value that i take from somewhere. i don't want to add this field and set it each time i make a new content, i want to have it all the time as default in all of the webforms.
(where i drag and drop whichever fields i wanna have in my survey/node, i wanna have a field that will always be there, and i will give it the title i want and the default value i want and everything).

the thing is, i wanna add a field to all of the webforms that i have, so if the website admin wanna add a new survey, there will be automatically a default field which i will set, and that field will get the value i wanna pass to the results table.
how do i do something like this?

thank you, Alexandra.

Comments

patrickkearney’s picture

The easiest way I can think of would be to use hook_form_alter and add the desired field to all forms. The only difference between modifying one specific form or all forms is instead of this in the example:
if ($form_id == 'module_formname') {
You can do if ($form_id !== '') {

The full example and documentation for hook_form_alter:
https://www.drupal.org/node/1702628

Hope that helps,

Patrick