As an example I have a translatable model:
class Settings extends Model {
public $implement = [
'System.Behaviors.SettingsModel',
'RainLab.Translate.Behaviors.TranslatableModel'
];
public $settingsCode = 'zollerboy_customtheme_settings';
public $settingsFields = 'fields.yaml';
public $translatable = [
'site_name',
//I have a lot more here
];
}
My fields.yaml
looks like this:
tabs:
fields:
site_name:
tab: Info
label: Website Name
type: text
# And so on ...
Is it possible, that I give the field site_name
a default value for each language?
I tried it with
default: name.plugin::lang.settings.default.site_name
but that seems to just work with labels but not with default values.
Yes, the default option does not work with translations, but you can display this field through of the widget form, getting the default value in the visualization method.
Register form widgets by overriding the registerFormWidgets method inside the Plugin registration class.
Example fields.yaml: