Hi,
My company has a moodle block where we have a string folderId setting that contains a unique key that maps to a folder in our product. The key is stored as "xxxxx-xxxxx-xxxxx-xxxxx".
I got a request to automatically trim any input into this field so that if a user inputs
" xxxxx-xxxxx-xxxxx-xxxxx-xxxxx "
or any beginning/ending whitespace combination will get saved as
"xxxxx-xxxxx-xxxxx-xxxxx-xxxxx"
and still work properly.
I was hoping there was a config_save like function that gets hit any time the global block settings are saved, but it looks like this was removed in Moodle 2.5. Is there any replacement function or alternate method I can user to override and trim this setting, I would prefer to do this in one place instead of finding all places this setting is used and sanitizing it there.
Thanks,
Joe M.
You should be using admin settings, defined through a settings.php file in your block https://docs.moodle.org/dev/Admin_settings, the same as for any other plugin.
If you need custom behaviour, then you can make your own subclass of admin_setting_configtext with the extra logic.