Cms: Form options no output

Created on 25 Feb 2020  Â·  3Comments  Â·  Source: statamic/cms

{{ fields }}
{{ options }}
{{ key }} {{ value }}
{{ /options  }}
{{ /fields }}

Key and value giving no output, but the array is shown in the dump:

  "options" => array:3 [â–¼
    "key_1" => "value"
    "key_2" => "value"
    "key_3" => "value"
  ]
not a bug

Most helpful comment

Accessing by looping through key/value only works when array is indexed (keys of 0, 1, 2, 3). You can do this:

{{ fields }}
  {{ options:key_1 }}
  {{ options:key_2 }}
  {{ options:key_13}}
{{ /fields }}

Or you can use the foreach tag.

All 3 comments

Accessing by looping through key/value only works when array is indexed (keys of 0, 1, 2, 3). You can do this:

{{ fields }}
  {{ options:key_1 }}
  {{ options:key_2 }}
  {{ options:key_13}}
{{ /fields }}

Or you can use the foreach tag.

foreach works perfectly. Thank you @jackmcdade !

My pleasure!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

austenc picture austenc  Â·  3Comments

dakisan picture dakisan  Â·  4Comments

jimblue picture jimblue  Â·  3Comments

jcohlmeyer picture jcohlmeyer  Â·  4Comments

sandervanh picture sandervanh  Â·  4Comments