Here is the problem: On a D7 community site, upgraded from D6, users are allowed to create new forum threads using node/add/forum link. In the node creation page ,they have to choose which forum their thread belongs to.

The default forum in the drop-down menu is set to '-None-' . So users who do not choose any forum, end up creating their thread in the 'None' forum, which then appears as the first forum and is obviously not desirable.

I am wondering who to get rid of this annoying problem?

1 Answer 1


Bit late, but someone else might find this useful.

My method was to use my theme template.php in D7 to modify the form:

  1. Add an entry to the list of forums (I only had a simple, non-hierachical list) e.g. $form['taxonomy_forums']['und']['#options']['0'] = '-choose a forum-';
  2. Add a validation function to the form. $form['#validate'][] = 'cirqasupport_validate_forum_area';
  3. In the validation function test the 'tid' being returned and if it was zero return an error on the forum field.

For example, add the following to template.php for your theme (or it could be done in a new module instead):

function mytheme_form_forum_node_form_alter(&$form, &$form_state){
   // force user to select a forum by putting a blank one at the top
   // and then checking that it is not what gets returned
   $form['taxonomy_forums']['und']['#options']['0'] = '-choose a forum-';
   $form['#validate'][] = 'mytheme_validate_forum_area';

and the validation function:

function mytheme_validate_forum_area($form, &$form_state){
   // A taxonomy_forum tid of 0 means they haven't selected one
   if ($form_state['values']['taxonomy_forums']['und'][0]['tid'] == '0')
   form_set_error('taxonomy_forums', t('You must select a forum.'));

The only problem I found is that the blank forum went in at the bottom of the sorted list no matter what number I gave it or how it was named.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.