{# Creates all the markup required for an date fieldset. Handles matching labels to inputs, error messages and other useful elements. name - The name of the form parameter. id - The id to use on the input and label. Convention is to prefix with 'field-'. label - The human readable label. value - The value of the input. error - A list of error strings for the field or just true to highlight the field. is_required - Boolean of whether this input is required for the form to validate with_date_picker - Boolean indicating whether the data picket should be used #} {% macro date(name, id='', label='', value=none, error="", is_required=false, with_date_picker=false, attrs={}) %} {% set id = id or name %} {% if value is none %} {% set value = ['','',''] %} {% elif value is string %} {% set value = value.split("-") %} {% endif %} {% set dp_fieldset_cls = ' nsw-date-input js-date-input' if with_date_picker else '' %} {% set dp_wrapper_cls = ' nsw-date-input__wrapper js-date-input-multiple' if with_date_picker else '' %} {% set dp_day_cls = ' js-date-picker-date' if with_date_picker else '' %} {% set dp_month_cls = ' js-date-picker-month' if with_date_picker else '' %} {% set dp_year_cls = ' js-date-picker-year' if with_date_picker else '' %} {% set dp_button %} {% if with_date_picker %}
{% endif %} {% endset %}
{{ label or name }} {{ caller and caller() }}
{{ dp_button | safe }}
{% if error %} {{ error if error is string else error|join(", ") }} {% endif %}
{% endmacro %}