Once upon a time, on a dark day, December 21st, 2011 to be exact. There was a desire to modify a Drupal webform. Normally, one could use replacement pattern tokens available in the Webform UI to set default values on a component field. But this was a special day, a day where a Webform field had to be prepopulated with a value that was not available via replacement pattern tokens. So if you need to modify a Webform via hook_form_alter, try something like this:
function my_module_form_alter (&$form, &$form_state, $form_id) {
// replace #### with your webform node id
if ($form_id == "webform_client_form_20111221") {
// replace 'full_name' with your webform's field_key value
$form['submitted']['full_name']['#default_value'] = "Joey Budafuko";
}
}
Today is December 21st, 2011. I hope you enjoyed our trip around the sun. Cheers to another revolution... around the sun!
Add new comment