Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

The Array Field in blueprints.yaml

Started by Muut Archive 10 years ago · 6 replies · 1621 views
10 years ago

Please tell me how to get the array of fields from blueprints.yaml form, something like the type of meta.name and meta.content, but with custom settings.
Example:

YAML
form:
  fields:
    tabs:
      type: tabs
      active: 1
      fields:
        service:
          type: tab
          title: Services
          fields:
            header.service:
              name: service
              type: list
              label: Block
              fields:
                .title:
                  type: text
                  label: Title
                  help: Title 
               .doctors:
                  type: array
                  label: Doctors
                  help: Doctors
                  placeholder_key: KEY
                  placeholder_value: VALUE
                  required: true

{{ service.title }} works and gives the Title, but {{ service.doctors }} displays just the word: array
Thanks!

10 years ago

Of course I use tags to output the Title for example:

TWIG
{% for service in page.header.service %}
{{ service.title }}
{% endfor %}

But how do I get the array? About it no where does it say.

10 years ago

Should be something like metadata. For example:

TWIG
{% for meta in page.metadata %}
<meta {% if meta.name %}name="{{ meta.name }}" {% endif %} {% if meta.content %}content="{{ meta.content }}" {% endif %}/>
{% endfor %}

But in this case .name and .content not working

10 years ago
TWIG
{% for doc in service.doctors %}
  {{ loop.index }}: {{ doc }}
{% endfor %}
10 years ago

Thanks! Just a little misunderstood. I got this:

TWIG

<ul>
       {% for key, doctor in service.doctors %}
       <li>{{ key }} - {{ doctor }}</li>
        {% endfor %}
</ul>
---
👍 1

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1999 9 years ago
Archive · by Muut Archive, 9 years ago
2 1342 9 years ago
Archive · by Muut Archive, 9 years ago
2 4549 9 years ago
Archive · by Muut Archive, 9 years ago
1 3401 9 years ago
Archive · by Muut Archive, 9 years ago
3 1493 9 years ago