I am using the webform module for Drupal 6 and would like to set a default value for the confirmation message of the webform whenever it is created. Would I have to create my own module to set this form value whenever a user creates a new webform? Or would I have to implement a special hook to look for when a webform is created?
-
Are you talking about whenever a user actually creates a new webform, or when a user fills out an already created webform?Mike Crittenden– Mike Crittenden2010-02-23 00:32:17 +00:00Commented Feb 23, 2010 at 0:32
-
When a user creates a new webform.JR.– JR.2010-02-23 17:08:07 +00:00Commented Feb 23, 2010 at 17:08
-
Right now I'm currently going the module route, writing a custom module that implements hook_form_alter and says if($form_id == 'webform_node_form') set the default value of the confirmation message. Don't know if it'll work though still banging away on it now.JR.– JR.2010-02-23 17:10:07 +00:00Commented Feb 23, 2010 at 17:10
-
Still no luck with hook_form_alter trying all sorts of variations of it. trying function named webform_node_form_form_alterJR.– JR.2010-02-23 18:10:21 +00:00Commented Feb 23, 2010 at 18:10
-
Gotten this far now. function customMod_form_alter(&$form, $form_state, $form_id){ if($form_id == 'webform_node_form'){ $node = $form['#node']; $webform = $node->webform; $node->webform['confirmation'] = "test test test"; The hook is executing and the array value is being set, but it still isn't appearing in the text field of the form.JR.– JR.2010-02-23 19:11:51 +00:00Commented Feb 23, 2010 at 19:11
Add a comment
|
2 Answers
You going to want to use the following:
customMod_form_alter(&$form, $form_state, $form_id){
if($form_id == 'webform_node_form'){
$form['id_of_conf_message_field']['#default_value'] = 'BLAH BLAH'
}
}
3 Comments
JR.
This is what I ended up doing, custom module and hook_form_alter... Thanks!
esafwan
But how do i do this in case of hidden field in web forms? its doesnt have id\
Felix Eve
This solution did not work for me however this answer did work.
@esafwan .. I'm not sure whether this shall help in your case with the hidden fields issue but I found this link for default variable values http://drupal.org/node/296453 so I was able to create a hidden field in my already existent webform with default value %request[key] and worked perfectly ..