/**
* Implements hook_form_alter.
* Client wants the subject field to initially be blank.
* If the user doesn't type in a subject line, then the
* node title should be inserted in the subject field.
*/
function my_module_form_alter($form_id, &$form) {
switch ($form_id) {
case 'comment_form' :
if ($site == 'comments') {
$form['#submit']['my_module_comment_form_submit'] =
array($subject);
/**This next line was the solution to my problem from the FAPI handbook page:
* http://drupal.org/node/58689
* By reversing the order of the submits, my submit gets done and the default
* comment form submit doesn't overwrite my desired subject line.
*/
return $form;
}
break;
}
}
function my_module_comment_form_submit($form, $form_values, $subject) {
/**
* Note: this code almost works, for some reason only the first part of the string
* gets passed with the $subject parameter, i.e. subject line is always 'Re: ' - node
* title doesn't get passed. I'll figure this out next.
*/
if ($form_values['subject'] == '') {
$form_values['subject'] = $subject;
}
}