file (and similar for any other locales you want to support) with the same English tokens but with language specific values and the plugin will use that instead of falling back to the English.
I was looking how to create a site setting that validates a username, but found there’s a username type to do this. Here the list of site setting types we have today:
email
username
integer
regex
string
list
enum
Also, you can do custom validations for your plugin settings, it accepts a validator field that expects a Ruby class. You use it like this.
Again you need to use a Computed Property and format as safe html. This is EmberJS not vanilla JavaScript. You can’t put ‘code’ directly into templates. Read the ember guides.
Even though type_supervisor.load_setting is not directly passed the value, it has access to the defaults because they are being passed in when the TypeSupervisor is initialized via DefaultsProvider.
type_supervisor.load_setting then calls get_data_type which calls parse_value_type() which should raise an ArgumentError if the type cannot be detected.
I think this whole sequence is called by load_settings in the SiteSetting model, and I don’t see any exception handling anywhere in the stack. But I’m not seeing any error output in the server log, or anywhere else.
It seems like there should be some kind of user feedback or error log to say that a setting failed to parse.
If I understand, you’re saying that using -1 as the default value on a setting causes the “Settings” button not to appear. Can you reproduce this behavior every time?
That’s odd. I don’t see anything wrong with your settings, I’m not sure how it’s possible to fail in parsing.
Ok, I think in both cases (dev and production) it was because the folder in the plugins directory didn’t match county-fence. That is why the setting was not displaying, and maybe would cause other problems as well.
A complete listing of Site Settings types is available in the type_supervisor.rb code. Just above that you can also see the valid child keys that a Site Setting accepts.
A more advanced example which uses more of these options can be found in the discourse-welcome-link theme component. These same values should work inside a plugin, but the file would instead be at config/settings.yml.