Contents

Backend\Widgets\Form\HasTranslatable

Overview

HasTranslatable adds translatable field popup support to the Form widget. Clicking the globe icon shows a dropdown of available sites/locales, and selecting one opens a popup to edit that single locale's field value.


Protected Properties

protected array $translatableSitesCache

translatableSitesCache keyed by filter type ('locale' or 'currency')


Public Methods

public getTranslatableSites()

public getTranslatableSites($model, $field = null): void

getTranslatableSites returns available sites for translation or currency override, excluding the current site. When a field is provided, the filter type is determined per-field: currency fields show sites with different currencies, while locale fields show sites with different locales.

public onLoadTranslateField()

public onLoadTranslateField(): void

onLoadTranslateField AJAX handler to open the translate popup for a single site

public onSaveTranslateField()

public onSaveTranslateField(): void

onSaveTranslateField AJAX handler to save a single site's translation

Protected Methods

protected bindTranslatableToController()

protected bindTranslatableToController(): void

bindTranslatableToController rebuilds the translate popup form when a request targets one of its widgets, so their AJAX handlers can run.

protected getTranslatableSite()

protected getTranslatableSite($siteId): void

getTranslatableSite returns a single site definition by ID

protected getTranslatableSiteModel()

protected getTranslatableSiteModel($model, $site): void

getTranslatableSiteModel returns the model for a specific site context

protected getTranslateSessionKey()

protected getTranslateSessionKey($site): string 

getTranslateSessionKey returns the deferred binding session key for a translate popup, kept apart from the main form and other sites.

protected makeTranslateFormWidget()

protected makeTranslateFormWidget($field, $siteModel, $site): void

makeTranslateFormWidget creates a Form widget instance for a single site/locale