A list of checkbox fields
The checkboxes field displays any number of checkboxes in a list. This is perfect if you have a predefined number of options a user can select from.
fields:
categories:
label: Categories
type: checkboxes
options:
design: Design
architecture: Architecture
photography: Photography
3d: 3D
web: Web
fields:
categories:
label: Categories
type: checkboxes
default: architecture
options:
design: Design
architecture: Architecture
photography: Photography
3d: 3D
web: Web
fields:
categories:
label: Categories
type: checkboxes
default:
- architecture
- web
options:
design: Design
architecture: Architecture
photography: Photography
3d: 3D
web: Web
Instead of defining options yourself, you can use an array of predefined dynamic ways to provide options:
fields:
category:
label: Category
type: checkboxes
default: architecture
options: children
Option | Description |
---|---|
children | List of options with all children |
visibleChildren | List of options with all visible children |
invisibleChildren | List of options with all invisible children |
pages | List of options with all pages of the site |
siblings | List of options with all siblings |
files | List of options with all files of the page |
images | List of options with all images of the page |
documents | List of options with all documents of the page |
videos | List of options with all videos of the page |
audio | List of options with all audio files of the page |
code | List of options with all code files of the page |
archives | List of options with all archives of the page |
An even more powerful way of generating dynamic options is the query option:
fields:
category:
label: Category
type: checkboxes
default: architecture
options: query
query:
page: downloads
fetch: files
value: '{{filename}}'
text: '{{filename}}'
flip: true
Option | Default | Description |
---|---|---|
page | current page | Any page URI. This is a powerful way to fetch any kind of data from any other page. |
fetch | children | See the list above for possible options |
value | {{uid}} | A string to be used for the value attribute. You can use {{varname}} for any object method from the passed object (page or file) |
text | {{title}} | A string to be used for the displayed option text. You can use {{varname}} for any object method from the passed object (page or file) |
flip | false | If true, the list of options will be reversed |
template | false | A template name that will filter out all items with a different intended template |
Specifying the column
option lets you change the number of option items that are displayed per row in the panel (1 till 5, default: 2).
fields:
category:
label: Category
type: checkboxes
options: children
columns: 3
A checkboxes field stores all selected categories in a comma separated list (value1, value2, value3) You can split this list in your templates and then work with the values like this:
<ul>
<?php foreach($page->categories()->split() as $category): ?>
<li><?php echo html($category) ?></li>
<?php endforeach ?>
</ul>