Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unique fieldnames in collections #1283

Open
wants to merge 1 commit into
base: 5.2
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions docs/fields/collection.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ along with the definition of the sub fields under the `fields` key.
features:
type: collection
fields:
title:
featuretitle:
type: text
image:
featureimage:
type: image
extensions: [ gif, jpg, png ]
content:
featurecontent:
type: html
```

Expand Down Expand Up @@ -78,7 +78,7 @@ fields from the collection by name or by type. Because of the nature of a Collec
In that light, it's usually good practice to always use a for loop to iterate over them. The examples below will grab the fields named `content` or all of the `type: text` fields. We do this with Twig's [`filter` filter][filter]

```twig
{% for feature in record.features|filter(feature => feature.name == 'content') %}
{% for feature in record.features|filter(feature => feature.name == 'featurecontent') %}
{{ feature }}
{% endfor %}

Expand Down Expand Up @@ -114,12 +114,12 @@ The field has three specific options:
limit: 3
collapsible: false
fields:
title:
featuretitle:
type: text
image:
featureimage:
type: image
extensions: [ gif, jpg, png ]
content:
featurecontent:
type: html
```

Expand All @@ -134,23 +134,23 @@ The field has three specific options:
features:
type: collection
fields:
title:
featuretitle:
type: text
content:
featurecontent:
type: html
image:
featureimage:
type: image
default:
0:
field: title
field: featuretitle
default: "Lets start with a title"
1:
field: image
field: featureimage
default:
filename: "kitten.jpg"
alt: "Picture of a kitten"
2:
field: content
field: featurecontent
default: "<strong>Finish strong</strong> after the kitten with some content"
```

Expand Down