public function updateCMSFields(FieldList $fields)
    {
        parent::updateCMSFields($fields);

        if (!isset(self::$collectorCache[$this->owner->class])) {
            return;
        }

        // remove all localized fields from the list (generated through scaffolding)
        foreach (self::$collectorCache[$this->owner->class] as $translatableField => $type) {
            $fields->removeByName($translatableField);
        }

        // check if we're in a translation
        if (Translatable::default_locale() != Translatable::get_current_locale()) {
            /** @var TranslatableFormFieldTransformation $transformation */
            $transformation = TranslatableFormFieldTransformation::create($this->owner);

            // iterate through all localized fields
            foreach (self::$collectorCache[$this->owner->class] as $translatableField => $type) {
                if (strpos($translatableField, Translatable::get_current_locale())) {
                    $basename = $this->getBasename($translatableField);

                    if ($field = $this->getLocalizedFormField($basename, Translatable::default_locale())) {
                        $fields->replaceField($basename, $transformation->transformFormField($field));
                    }
                }
            }
        }
    }
public function updateCMSFields(FieldList $fields)
    {
        parent::updateCMSFields($fields);

        if (!isset(self::$collectorCache[$this->owner->class])) {
            return;
        }

        // remove all localized fields from the list (generated through scaffolding)
        foreach (self::$collectorCache[$this->owner->class] as $translatableField => $type) {
            $fields->removeByName($translatableField);
        }

        // check if we're in a translation
        if (Translatable::default_locale() != Translatable::get_current_locale()) {
            /** @var TranslatableFormFieldTransformation $transformation */
            $transformation = TranslatableFormFieldTransformation::create($this->owner);

            // iterate through all localized fields
            foreach (self::$collectorCache[$this->owner->class] as $translatableField => $type) {
                if (strpos($translatableField, Translatable::get_current_locale())) {
                    $basename = $this->getBasename($translatableField);

                    if ($field = $this->getLocalizedFormField($basename, Translatable::default_locale())) {
                        $fields->replaceField($basename, $transformation->transformFormField($field));
                    }
                }
            }
        }
    }
public function updateCMSFields ( FieldList $ fields ) { parent :: updateCMSFields ( $ fields ) ; if ( ! isset ( self :: $ collectorCache [ $ this -> owner -> class ] ) ) { return ; } // remove all localized fields from the list (generated through scaffolding) foreach ( self :: $ collectorCache [ $ this -> owner -> class ] as $ translatableField => $ type ) { $ fields -> removeByName ( $ translatableField ) ; } // check if we're in a translation if ( Translatable :: default_locale ( ) != Translatable :: get_current_locale ( ) ) { /** @var TranslatableFormFieldTransformation $transformation */ $ transformation = TranslatableFormFieldTransformation :: create ( $ this -> owner ) ; // iterate through all localized fields foreach ( self :: $ collectorCache [ $ this -> owner -> class ] as $ translatableField => $ type ) { if ( strpos ( $ translatableField , Translatable :: get_current_locale ( ) ) ) { $ basename = $ this -> getBasename ( $ translatableField ) ; if ( $ field = $ this -> getLocalizedFormField ( $ basename , Translatable :: default_locale ( ) ) ) { $ fields -> replaceField ( $ basename , $ transformation -> transformFormField ( $ field ) ) ; } } } } }
Alter the CMS Fields in order to automatically present the
correct ones based on current language.
@inheritdoc
Alter the CMS Fields in order to automatically present the correct ones based on current language .