Add translation functionality to all form modes

Created on 27 December 2023, over 1 year ago

Problem/Motivation

Now a translation functionality is added only on forms with add and edit operations.

/**
 * Implements hook_form_alter().
 */
function content_translation_form_alter(array &$form, FormStateInterface $form_state) {
  ...
  // Let the content translation handler alter the content entity form. This can
  // be the 'add' or 'edit' form. It also tries a 'default' form in case neither
  // of the aforementioned forms are defined.
  if ($entity instanceof ContentEntityInterface && $entity->isTranslatable() && count($entity->getTranslationLanguages()) > 1 && in_array($op, ['edit', 'add', 'default'], TRUE)) {
    // Add translation functionality on the form.
  }
}

Steps to reproduce

I added form mode "Donation types".

But this form has operation = donation_types and no translation functionality has been added.

Proposed resolution

To add functionality to all form modes.

Feature request
Status

Active

Version

11.0 🔥

Component
Content translation 

Last updated 10 days ago

No maintainer
Created by

🇷🇸Serbia super_romeo Belgrade

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024