field storage config should document what it means for translatable to be FALSE

Created on 24 April 2023, about 2 years ago

Problem/Motivation

FieldStorageConfig says:

  /**
   * Flag indicating whether the field is translatable.
   *
   * Defaults to TRUE.
   *
   * @var bool
   */
  protected $translatable = TRUE;

but there's AFAICT no UI for setting this to FALSE. The translatability is controlled at the field config level, not in the storage.

What would it mean if this property were FALSE?

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

๐Ÿ› Bug report
Status

Active

Version

10.1 โœจ

Component
Documentationย  โ†’

Last updated about 15 hours ago

No maintainer
Created by

๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom joachim

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

Comments & Activities

  • Issue created by @joachim
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Akram Khan Cuttack, Odisha

    added a patch and To improve the documentation for the FieldStorageConfig class, add a more detailed description of what the translatable property does and what it means when it's set to FALSE.

  • last update about 2 years ago
    29,304 pass
  • Status changed to Needs review about 2 years ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Akram Khan Cuttack, Odisha
  • Status changed to Needs work about 2 years ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom joachim
    +++ b/core/modules/field/src/Entity/FieldStorageConfig.php
    @@ -129,7 +129,9 @@ class FieldStorageConfig extends ConfigEntityBase implements FieldStorageConfigI
    +   * language on a multilingual site. If FALSE, the field is not translatable and
    +   * will have the same value for all languages.
        *
    

    My point though is that AFAICT this NEVER gets set to FALSE. There is no UI for it, and fields get created with it set to TRUE.

    This needs input from people who know the deep innards of the translation system.

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium weseze

    Could this be the default value, when "Adding an existing field" to a content type?

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia priya.chat

    Hey @weseze,
    Answer to your question is No, this is not the default value set when "adding an existing field" to a content type. The translatable flag is a property of the field storage, not the field instance. This means it is defined once when the field is originally created and applies globally to that field across all bundles (content types, for example).

    When you add an existing field to another content type, Drupal uses the existing FieldStorageConfig definition, including its translatable setting. So the value of translatable is inherited from the original field storage configuration and cannot be changed for each individual instance.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia priya.chat

    Adding a patch to update the doc block for translatable in FieldStorageConfig.

    While the default is usually TRUE, it can be explicitly set to FALSE during field creation (especially via code). Once set, the value is fixed and governs the behaviour across all field instances โ€” the โ€œTranslatableโ€ checkbox at instance level has no effect if the storage is non-translatable. Thanks.

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium weseze

    It can be changed on a per instance basis... The config file for a field instance allows this. Also the translation interface for for example node-types > fields allows this.

  • The Needs Review Queue Bot โ†’ tested this issue.

    While you are making the above changes, we recommend that you convert this patch to a merge request โ†’ . Merge requests are preferred over patches. Be sure to hide the old patch files as well. (Converting an issue to a merge request without other contributions to the issue will not receive credit.)

Production build 0.71.5 2024