Forms, fields and service
Use these filters when a template needs field or form output, component visibility information or the current repeating-row context. Pass inner field IDs—not an outer group ID—and test hidden, blank and repeated values.
Standard Liquid filters
These filters are provided as standard by the Liquid language. They are available anywhere Govforms accepts a Liquid template.
| Filter | What it does | Example |
|---|---|---|
default(fallback) | Provides fallback for empty values Returns fallback if input is null, undefined, or empty string. | {{ empty_var | default: "N/A" }} → N/A |
first() | Gets first element of array Returns first item in array or first character of string. | {{ "hello" | first }} → h |
json() | Converts value to JSON string Serializes value as JSON. | {{ my_object | json }} → {"key":"value"} |
last() | Gets last element of array Returns last item in array or last character of string. | {{ "hello" | last }} → o |
map(property) | Extracts property from array of objects Creates array of property values from object array. | {{ users | map: "name" }} → array of name values |
size() | Returns size of array or string Gets length/count of elements. | {{ "hello" | size }} → 5 |
where(property, expected) | Selects matching array items Returns objects whose property equals the expected value. If expected is omitted, the property must be truthy. | {{ users | where: "active", true | json }} |
Govforms filters
These filters are added by Govforms for service-building and data-handling tasks.
| Filter | What it does | Example |
|---|---|---|
field_to_text(field_value, field_id, field_defs, part_id) | Converts field value to display text Formats field value according to field type for display. | {{ my_field_value | field_to_text: "field1", form.fieldDefs }} |
form_to_json(form) | Converts form data to JSON object Extracts all field values into clean JSON structure. | {{ form | form_to_json }} |
form_to_text(form, newlines) | Converts form data to formatted text Creates human-readable text summary of form data. | {{ form | form_to_text: 2 }} |
is_editing_table_group_iteration(field_in_group_id) | Checks if currently editing table group row Pass the ID of a field inside the group. The group itself is not addressed by ID. | {{ "line_item_name" | is_editing_table_group_iteration }} |
is_hidden(field_id) | Checks if field is hidden by conditional logic Returns true if field is currently hidden by show/hide rules. | {{ "conditional_field" | is_hidden }} |
is_visible(field_id) | Checks if field is visible Returns true if field is currently visible (opposite of is_hidden). | {{ "conditional_field" | is_visible }} |
not(boolean) | Logical NOT operation Returns opposite boolean value. | {{ true | not }} → false |
show_hidden_component(change_text, reset_text, visually_hidden_prefix, visually_hidden_suffix, field_id, classes, iteration, dont_save) | Creates toggle for hidden form components Generates button to show/hide optional form fields. | {{ "Add details" | show_hidden_component: "Remove details", "", "", "optional_field", "btn-link" }} |
