Download the PHP package arillo/silverstripe-arbitrarysettings without Composer
On this page you can find all versions of the php package arillo/silverstripe-arbitrarysettings. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download arillo/silverstripe-arbitrarysettings
More information about arillo/silverstripe-arbitrarysettings
Files in arillo/silverstripe-arbitrarysettings
Package silverstripe-arbitrarysettings
Short Description Arbitrary settings for DataObjects
License MIT
Homepage https://github.com/arillo/silverstripe-arbitrarysettings
Informations about the package silverstripe-arbitrarysettings
arillo/silverstripe-arbitrarysettings
Extends a DataObject with a mutil value field to store arbitrary settings in it.
Requirements
SilverStripe CMS ^5.0
- For a SilverStripe 4.x compatible version of this module, please see the 2 branch.
- For a SilverStripe 3.x compatible version of this module, please see the 1 branch, or 0.x release line.
Usage
Add and setup the extension on your DataObject
e.g. in config.yml:
Note: All keys should be alphanumeric (including underscores, haven't tested other special characters yet) and should not contain whitespace.
To add the field in CMS you can use a helper method to show the field:
Values can be accessed like this:
in templates:
SettingsField
has functions available to manipulate the source of the field:
For including or excluding certain setting you can use:
It is also possible to update the default value for a setting (for sure only if its present as an option):
Settings presets
It is possible to define a list of setting presets like this:
With these presets defined it is possible to reference these keys in your DataObject's settings config, e.g.:
Translations
To translate the form field label used by SettingsExtension::field_for
can be changed like this:
To translate options follow the following convention: