How to remove language selector from new Forum topic creation page?

Events happening in the community are now at Drupal community events on www.drupal.org.
Anonymous's picture

I have a multilingual Drupal site using the core Forum module and Advanced Forums.

When users create a new Forum topic, there is a Language selector drop-down menu allowing them to pick a language (Language Neutral, English, Japanese). How can I remove this menu item? I'm hoping there is a setting for this and I don't need a CSS hack ...

Users can post in my Forums in any language they want, so having them choose a language for their Forum topic post is kind of pointless. And because it is meaningless it can cause user confusion. (i.e., why is this option here? what does it do? which should I chose?)

Thanks!

Comments

hook_form_alter

aiwata55's picture

I think you can make any changes on an existing form with hook_form_alter.

http://api.drupal.org/api/function/hook_form_alter/6
http://api.drupal.org/api/drupal/developer--topics--forms_api.html/6
http://api.drupal.org/api/drupal/developer--topics--forms_api_reference....

Hope this help.

p.s.
Note that I am still learning programming for Drupal, so I can be wrong.


Aki Iwata
FOREST & trees

Probably but .... I'm still

totsubo's picture

Probably but ....

I'm still hoping there is a setting somewhere I overlooked :) Settings are so much easier to deal with than code changes ...

I think aiwata55 is correct

Antoine Lafontaine's picture

I think aiwata55 is correct on this one, you will probably need to unset that form element in a form_alter or maybe you can also get away with it in a preprocess function (unsetting the rendered form element).

You do not need to change any code in any of the modules (never forget that hacking core kills kittens)... or you meant you'd prefer not to use code to solve this one ;)

No kittens where hurt during the production of this comment ...

totsubo's picture

You're right Antoine, I meant that I preferred not to use code.

Drupal has so many options that I'm always worried that I missed one somewhere. But I guess in this case there is no other way.

Thanks all!

totsubo's picture

Thanks guys for the help. I was able to achieve what I wanted by adding this function to a custom module and unsetting the form element for the drop-down:

/**
* Implementation of hook_form_alter().
*
* The function is named modulename_form_alter.
*/
function custommod_form_alter(&$form, $form_state, $form_id) {
// Normally a switch is used because you may want to alter more than
// one form and it is easy to add a new case for each form.
switch ($form_id) {
// This is our form ID.
case 'forum_node_form':
unset($form['language']);
break;
}
}

I found these tutorials useful:

http://www.lullabot.com/articles/modifying-forms-drupal-5-and-6
http://www.blip.tv/file/212829/

日本 コミュニティ: Drupal Japan User Group

Group organizers

Group categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: