Background and strategic fit
Add the composite plugin to your ckan.plugins configuration settings and use ckanext-scheming or a custom form plugin to use the provided validators to provide subfields for the metadata fields.
This for example is required for the fields that each contains more sub-attributes such as author with subfields such as name, email address, etc..
Installations and Requirements
To install ckanext-composite on a production site:
Activate your CKAN virtual environment, for example:
ENV /usr/lib/ckan/default/bin/activate
Install the ckanext-composie Python package into your virtual environment:
pip install ckanext-composite // or pip install -e git+https://github.com/EnviDat/ckanext-composite#egg=ckanext-composite
Add the relevant plugins to the
ckan.pluginssetting in your CKAN config file.Add
ckanext.composite:presets.jsonto your scheming. presets configuration settings:scheming.presets = ckanext.scheming:presets.json ckanext.repeating:presets.json ckanext.composite:presets.jsonRestart CKAN. For example, if you've deployed CKAN with Apache on Ubuntu:
sudo service apache2 reload
User interaction and design
Add this to your schema.json file:
# Composite Field
{
"field_name": "maintainer",
"label": "Maintainer",
"preset": "composite",
"subfields":[
{
"field_name": "name",
"label": "Name",
"form_placeholder": "Joe Bloggs"
},
{
"field_name": "email",
"label": "Email",
"form_placeholder": "joe@example.com"
},
{
"field_name": "date",
"label": "Date",
"preset": "date",
"form_placeholder": "yyyy-mm-mm"
},
{
"field_name": "identifier_scheme",
"label": "Scheme",
"preset": "select",
"choices": [
{
"value": "orcid",
"label": "ORCID"
},
{
"value": "isni",
"label": "ISNI"
}
]
}
]
}
# Composite Repeating Field
{
"field_name": "author",
"label": "Authors",
"preset": "composite_repeating",
"form_blanks": 1,
"subfields": [
{
"field_name": "name",
"label": "Name",
"form_placeholder":"eg. John Smith"
},
{
"field_name": "type",
"label": "Type",
choices = [
{
"value": "collaborator",
"label": "Collaborator"
},
{
"value": "editor",
"label": "Editor"
}
]
}
]
}
Questions and Answers
Below is a list of Q&A from user sides:
| Question | Answers |
|---|---|