Adds i18n support for the form field default property (#3546)

Credit to @Farrow. Previously when creating a backend form with RainLab.Builder if you filled in the "Default" property using the i18n (to get, for example, acme.plugin::lang.field.default) then that string would be output exactly on the form (i.e. <input value="acme.plugin::lang.field.default"...>) instead of being replaced with the actual value of that key from the lang file.
This commit is contained in:
Farrow 2018-12-01 19:05:47 +00:00 committed by Luke Towers
parent 8e9b3dba54
commit a1fb23a984

View File

@ -1071,7 +1071,7 @@ class Form extends WidgetBase
}
$defaultValue = !$this->model->exists
? $field->getDefaultFromData($this->data)
? trans($field->getDefaultFromData($this->data))
: null;
return $field->getValueFromData($this->data, $defaultValue);