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?
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.
Sign up to join this communityI 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?
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>';
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.
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;
}
you can disable it from drupal go to admin/config/regional/i18n/select
just tick "Hide content translation links"