Skip to content

Commit

Permalink
Document select field
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeldfallen committed Oct 18, 2017
1 parent e9f6f78 commit 1307855
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion templates/look-and-feel/components/fields.njk
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,20 @@
</div>
{% endmacro %}

{#
select
field - (required) A field object containing name, id and value
label - (required) The label to apply to the field
hint - (default = '') Extra hint text to place under the label
hideLabel - (default = false) Hides the selects label (for when a this element is the only field on the page)
options - (default = []) Options used to populate the possible answers
options.label - (required) The label text to display for this option
options.value - (default = label.lowercase()) The value to be sent on post for this option
options.disabled - (default = false) Prevent the option from being selected
Renders a select box with multiple options
#}
{% macro select(field,
label,
hint='',
Expand All @@ -132,7 +146,11 @@
name="{{ field.id }}"
class="form-control">
{# Default option so no option is preselected #}
<option disabled selected value style="display: none"></option>
<option disabled
{% if not field.value %}
selected
{% endif %}
value style="display: none"></option>

{% for option in options -%}
{% set option_value = option.value or option.label|lower %}
Expand Down

0 comments on commit 1307855

Please sign in to comment.