DrupalBin
Submit Code
About
Recent Posts
Code
9 min 46 sec
ago
How do i make this work in D6 (I have to clear the cache everytime to see the tabs)
3 hours 53 sec
ago
Code
3 hours 56 min
ago
Code
7 hours 54 min
ago
more
Tags
CCK
drupal
fapi
jquery
menu
module
Panels
php
simpletest
test
theme
views
more tags
User login
Log in using OpenID:
What is OpenID?
Username:
*
Password:
*
Create new account
Request new password
Log in using OpenID
Cancel OpenID login
Home
Fix for Trying to insert text into "subject" field of the comments form.
View
Download
Fix
This fix will not be saved to the database until you submit.
Summary:
Tags:
Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Source code:
*
/** * 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. * Currently in the code below, the form_alter puts the node title as the * #default_value in the subject field. */ function external_page_form_alter($form_id, &$form) { $site = strtok($_SERVER['SERVER_NAME'], '.'); switch ($form_id) { case 'comment_form' : if ($site == 'comments') { $subject = 'Re: ' . drupal_get_title(); $form['subject'] = array ( '#type' => textfield, '#title' => 'Subject', '#default_value' => decode_entities($subject), ); } break; } } function external_page_comment_form_validate($form_id, $form_values) { //Not validating anything just now. } function external_page_comment_form_submit($form, $form_values) { /** * Note: this code doesn't work, what happens is that if the subject field is blank * then it somehow gets populated with the first part of the first sentence i of the * text in the the comment field. */ if ($form_values['subject'] == '') { $subject = 'Re: ' . drupal_get_title(); $form_values['subject'] = $subject; //form_set_value($form_values['subject'], $subject); } }
Syntax highlighting mode:
ActionScript
ColdFusion
Diff
Drupal
Drupal 5
Drupal 6
HTML
Javascript
MySQL
PHP
Python
robots.txt
SQL
Text
Select the syntax highlighting mode to use.