I want to programmatically disable the content translation options located at the bottom of the content edit form (see yellow area in screenshot): enter image description here

I know that i can disable the revision information options with the following code in a form_alter hook:

$form['revision_information']['#access'] = false; // <--- works

But that doesn't work with the translation options, at least with what I tried:

$form['content_translation']['#access'] = false; // <--- doesn't work

So ideally, how can i disable the whole yellow area?


You can not access to content_translation property in the hook_form_alter but you can do it in after_build callback.

after_build: runs after the form or element is built for display.

Try with the following:

  1. Add #after_build to the form:
 *Implements hook_form_alter().
function myModule_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  if ($form_id == 'node_YouContentType_edit_form') {
    $form['#after_build'][] = 'myModule_after_build';

  1. Implement your after_build function

    function myModule_after_build($form, &$form_state){
      $form['content_translation']['#access'] = FALSE;
      return $form;

  • 1
    i'm glad that help! :) – berramou Jan 9 at 13:23

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.