Error message

Deprecated function: implode(): Passing glue string after array is deprecated. Swap the parameters in drupal_get_feeds() (line 394 of /home1/tylerfra/public_html/includes/common.inc).

Drupal Webform Alter

Category: 

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!

Comments

I tried your code and it works. I found that the comments was off, it diyelaspd 2 even though there really wasn't any comments. I found this to be a more suitable for me:

$vars['submitted'] = t(

'Published by !username at @datetime - !comments',

  array(

    '!username' => $vars['name'],

    '@datetime' => $vars['date'], 

  ),

  '!comments' => l(

    format_plural($vars['comment_count'], '1 comment', '@count comments'),

    drupal_lookup_path('alias',$vars['uri']['path']),

    array('fragment' => 'comments')

  )

);