You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The $has_one relation of DataObject renders in the admin as a dropdown. And if this relation doesn't have some default configured, it shows text Select an Option, for example, when creating a new instance of the DataObject class.
The text probably comes from some 3rd party, it doesn't seem to react to the browser language settings. The classes around the dropdown are: chosen-container chosen-container-single chosen-container-single-nosearch and chosen-single chosen-default.
Could you help me to identify the said 3rd party library and maybe find a way how to translate it? In the Silverstripe v3 there was no text visible.
How to reproduce
class A extends DataObject {
privatestatic$has_one = array(
'B' => 'B',
);
...
Possible Solution
No response
Additional Context
No response
Validations
Check that there isn't already an issue that reports the same bug
Double check that your reproduction steps work in a fresh installation of silverstripe/installer (with any code examples you've provided)
The text was updated successfully, but these errors were encountered:
You've given the css classes, but those are a lot less useful than what the actual underlying PHP FormField implementation is.
If it's being autoscaffolded, that will be a DropdownField. I've played around a bit with the code that scaffolds the form field. It turns out that ' ' is a bit magic. If that was an empty string, or a string containing some text, the empty string or text would be displayed. But for some reason chosen looks at the ' ' differently.
Make the text localisable only for DBForeignKey autoscaffolding
This would be adding something like ->setAttribute('data-placeholder', _t(__CLASS__ . '.SelectOption', 'Select an Option')) to the field
Make the text localisable for any DropdownField which has this setup
This would be more complicated, since it seems like it's being done as a fluke (that someone noticed and intentionally used in the autoscaffolding scenario).
This requires finding out what the exact conditions are which cause the default text to be used (e.g. is it a single space specifically? Or any amount of whitespace? etc) and setting a data-placeholder only in those scenarios.
As an aside, the autoscaffolded FormField for has_one relations is changing in Silverstripe CMS 5.2.
Option 1 is definitely the least intrusive - but it could result in unexpected behaviour in the (unlikely) scenario someone creates their own DropdownField with whitespace as the "empty string".
Given the extra complexity of option 2 though, I'd be okay with a PR that just implements the first option.
Module version(s) affected
2.1.17
Description
The
$has_one
relation ofDataObject
renders in the admin as a dropdown. And if this relation doesn't have some default configured, it shows textSelect an Option
, for example, when creating a new instance of theDataObject
class.The text probably comes from some 3rd party, it doesn't seem to react to the browser language settings. The classes around the dropdown are:
chosen-container chosen-container-single chosen-container-single-nosearch
andchosen-single chosen-default
.Could you help me to identify the said 3rd party library and maybe find a way how to translate it? In the Silverstripe v3 there was no text visible.
How to reproduce
Possible Solution
No response
Additional Context
No response
Validations
silverstripe/installer
(with any code examples you've provided)The text was updated successfully, but these errors were encountered: