Skip to content

Commit

Permalink
Unique fieldnames in collections
Browse files Browse the repository at this point in the history
Suggesting to have unique fieldnames in collections in the examples in the docs, related to bolt/core#3386

There may be more instances in the docs where this can apply.
  • Loading branch information
evertalbers authored Mar 26, 2024
1 parent baf9070 commit d37e506
Showing 1 changed file with 13 additions and 13 deletions.
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

0 comments on commit d37e506

Please sign in to comment.