Skip to content
This repository has been archived by the owner on Oct 13, 2021. It is now read-only.

pixelfear/Statamic-Field-Options

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

Statamic-Field-Options

Get a field's options from a fieldset.

Useful for grabbing options from a select fieldtype.

Usage

If your field has key/value options, like the following:

colors:
  type: select
  options:
    f00: Red
    0f0: Green
    00f: Blue

Then you can use {{ key }} and {{ value }} respectively:

<select>
{{ field_options field="colors" }}
  <option value="{{ key }}">{{ value }}</option>
{{ /field_options }}
</select>

But if you have unnamed keys, like so:

colors:
  type: select
  options:
    - Red
    - Green
    - Blue

{{ value }} will be all you need. (Since key here would just be indexes)

<select>
{{ field_options field="colors" }}
  <option value="{{ value }}">{{ value }}</option>
{{ /field_options }}
</select>

Parameters

  • fieldset: If your page doesn't have a _fieldset defined in the front-matter, you can specify your fieldset manually here.
  • field: The name of the field you want to grab options from.

About

Get a field's options from a fieldset

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages