Skip to content Skip to footer navigation
You are reading the Statamic 6 Alpha docs. πŸ‘€

Form-fields Tag

To be used within the form:create tag when dynamically rendering fields.

Example

This tag can recursively loop over the fields array context provided within the form:create tag pair.

{{ form:fields }}
<div class="p-2">
<label>{{ display }}</label>
<div class="p-1">{{ field }}</div>
{{ if error }}
<p class="text-gray-500">{{ error }}</p>
{{ /if }}
</div>
{{ /form:fields }}
<s:form:fields>
<div class="p-2">
<label>{{ $field['display'] }}</label>
<div class="p-1">{{ $field['field'] }}</div>
@if ($field['error'])
<p class="text-gray-500">{{ $field['error'] }}</p>
@endif
</div>
</s:form:fields>
Hot Tip!

Learn more about which fields array variables are available to this fields loop!

A troll pointing a teaching stick

Parameters

get

string

Get and render one specific field by its handle.

only

string

Loop over only the specified field handles (pipe separated).

except

string

Loop over all except the specified field handles (pipe separated).