symbiote / silverstripe-multivaluefield
A DB field + form fields for storing multiple values in a single property (serialized).
Installs: 365 874
Dependents: 55
Suggesters: 0
Security: 1
Stars: 47
Watchers: 10
Forks: 44
Open Issues: 4
Type:silverstripe-vendormodule
Requires
- php: ^8.1
- silverstripe/framework: ^5
Requires (Dev)
Replaces
- silverstripe/multivaluefield: 6.1.0
- 7.x-dev
- 6.x-dev
- 6.1.x-dev
- 6.1.0
- 6.1.0-rc1
- 6.1.0-beta1
- 6.0.x-dev
- 6.0.2
- 6.0.1
- 6.0.0
- 6.0.0-rc1
- 6.0.0-beta1
- 5.x-dev
- 5.4.x-dev
- 5.4.2
- 5.4.1
- 5.4.0
- 5.4.0-rc1
- 5.4.0-beta1
- 5.3.x-dev
- 5.3.0
- 5.2.x-dev
- 5.2.1
- 5.2.0
- 5.1.x-dev
- 5.1.1
- 5.1.0
- 5.0.x-dev
- 5.0.2
- 5.0.1
- 5.0.0
- 4.0.3
- 4.0.2
- 4.0.1
- 4.0.0
- 3.1.x-dev
- 3.1.2
- 3.1.1
- 3.1.0
- 3.0.x-dev
- 3.0.5
- 3.0.4
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
- 2.4.x-dev
- 2.4.4
- 2.4.3
- 2.4.2
- 2.4.1
- 2.4.0
- 2.3.x-dev
- 2.3.4
- 2.3.3
- 2.3.2
- 2.3.1
- 2.3.0
- 2.2.x-dev
- 2.2.4
- 2.2.3
- 2.2.2
- 2.2.1
- 2.2.0
- 2.1.x-dev
- 2.1.1
- 2.1.0
- 2.0.x-dev
- 2.0.6
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.1-rc1
- 2.0.0
- 1.0.x-dev
- dev-master
- dev-fix-mvfield-set-value
This package is auto-updated.
Last update: 2024-11-20 23:11:33 UTC
README
Notes:
- The Silverstripe 2.4 compatible version of the module is still available in the ss24 branch
- The Silverstripe 3.x compatible versions are still available in the 2.x branches. (see version info)
A database field type that allows the storage of multiple discrete values in a single database field. This also provides form fields for entering multiple values in a simple manner
- MultiValueTextField - displays a text field. When data is entered, another text field is displayed directly beneath. Subsequent data entry triggers more text fields to appear
- MultiValueDropdownField - displays a dropdown field. When a value is selected another dropdown field is displayed.
Within templates, the field can be iterated over as per a data object set. The property $Value is available as a Varchar type, and other typical properties such as $FirstLast etc are inherited from ViewableData.
Data is stored in the database in a serialized PHP format. While this is not ideal for searching purposes, some external indexing engines (eg the Solr module) are aware of the field type and will index accordingly.
Version info
This version of MultiValueField supports Silverstripe 4.0.0
Older versions of Silverstripe are supported on minor version branches below
Installation
composer require symbiote/silverstripe-multivaluefield
Basic Usage
As with all DB fields
private static $db = array(
'Keywords' => 'MultiValueField',
);
To make use of the field on the frontend, you can loop over the Items property
<% loop $Keywords.Items %> <p>$Key $Value</p> <% end_loop %>
In this case, $Value
is a Varchar object, so you can call all relevant string field methods on it, such as $Value.Raw
, $Value.LimitWordCount
etc etc.
Note that to have the $Key
value available as something other than an integer, use the KeyValueField
field type to populate the field.
You can set the key and value placeholder values of the KeyValueField in your field like this:
$kvf = KeyValueField::create(
'MultiChoiceAnswer',
'Multiple Choice Answers'
);
$kvf->setValueFieldPlaceholder('Value');
$kvf->setKeyFieldPlaceholder('Label');
Maintainer Contacts
- Marcus Nyeholt marcus@symbiote.com.au
Requirements
- Silverstripe 4.0
Contributing
Thanks
- Ingo's initial work to getting this SS4 ready
- muskie9's work on updating UI fields
Translations
Translations of the natural language strings are managed through a third party translation interface, transifex.com. Newly added strings will be periodically uploaded there for translation, and any new translations will be merged back to the project source code.
Please use https://www.transifex.com/projects/p/silverstripe-multivaluefield to contribute translations, rather than sending pull requests with YAML files.
License
This module is licensed under the BSD license at http://silverstripe.org/BSD-license