2

I would like to hide the language selector dropdown on node add pages of multilanguage enabled content types.

What would be the best way? A jquery selector perhaps?

  • I would not recommend jQuery selector because sometimes your client comes with a slow connection, and that will make the drop down to show while the page is loading, then it will disappear. – saadlulu Apr 18 '13 at 7:03
  • Ps I ended up using css drupalgardens.com/content/… – giorgio79 Apr 19 '13 at 8:51
3

Don't use jQuery for this. Better use hook_form_alter.

Check if user has target role. Print out your $form and find language select in printed array. Than hide language select.

There are 2 options for hiding:

1st:

$form['language']['#access'] = FALSE;

2nd:

$form['language']['#prefix'] = '<div class="element-invisible">';
$form['language']['#suffix'] = '</div>';
1

Depending on your needs, the default block settings configuration page may be all you need.

Go to admin/structure/blocks/manage and edit the language selector box. At the bottom of the screen, under Pages, set to show the block on All pages except those listed and then set the path to node/*/edit. If you need more fine-grained control, you can use the PHP code option.

1

First :

function myModule_form_alter(&$form, &$form_state){
 ....
 $form['#after_build'][] = 'my_custom_form_after_build';
}

Second:

function my_custom_form_after_build(&$form, &$form_state){
 $form['language']['#access']=FALSE;
}
0

you can disable it from drupal go to admin/config/regional/i18n/select

just tick "Hide content translation links"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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