Skip to content

Select & List Options

['Option 1', 'Option 2', 'Option 3']
[
{value: '1', label: 'Option 1'},
{value: '2', label: 'Option 2'},
{value: '3', label: 'Option 3'}
]
{
'Group 1': ['Option 1', 'Option 2'],
'Group 2': ['Option 3', 'Option 4']
}
{
'Group 1': [
{value: '1', label: 'Option 1'},
{value: '2', label: 'Option 2'}
],
'Group 2': [
{value: '3', label: 'Option 3'},
{value: '4', label: 'Option 4'}
]
}

Populate options from all unique values of a property in the current collection:

{
"propertyOptions": true
}

Populate options from another collection:

{
"relationalOptions": {
"collection": "categories",
"label": "title",
"value": "id"
}
}
"settings": {
"propertyOptions": true,
"relationalOptions": {
"collection": "mycollection",
"label": "name",
"value": "id"
}
}

Sort options alphabetically in select/list fields:

{
"sortOptions": true
}
{{ cms.form.select("myselect", {}, {
options: {
"1": "One",
"2": "Two",
"3": "Three"
}
}) }}
{% set options = [
{value: "dog", label: "Dog"},
{value: "cat", label: "Cat"},
{value: "hamster", label: "Hamster"},
{value: "parrot", label: "Parrot"},
{value: "spider", label: "Spider"},
{value: "goldfish", label: "Goldfish"}
] %}
{% set form = cms.form.builder('pets') %}
{{ form.field('pet', {
field: 'select',
options: options
}) }}
{{ cms.form.select("category", {}, {
settings: {
relationalOptions: {
collection: "categories",
label: "title"
}
}
}) }}