Chromium's date input lets the year part take six digits when the input has no max, so typing 2026 and then 11 for the month gave 202611-12-05 (reported on the live app). Every date input now carries min="1900-01-01" and max="2100-12-31", so the year part stops at four digits and moves on to the month. Checked in Edge: typing 20261112 gives 2026-11-12, where it left the field empty before. The server checks the same years for every date field (dates::parse_form_date). Person, passport and address dates were only parsed, so a two-digit year such as 0026-11-12 would have been saved; stay records had the range already. A six-digit year never parsed, so no such date can be in the database. Tests: the parser's cases; the person, passport and arrival forms refuse both years and save nothing; every date input on every page carries the limits (pages.rs).
47 lines
2.4 KiB
HTML
47 lines
2.4 KiB
HTML
{#- Form fields. Every field has a label, its error under it and the
|
|
error tied to the input for screen readers. -#}
|
|
|
|
{% macro text(name, label, value="", err="", hint="", req=false, type="text", list="", auto="off", cls="", ph="") -%}
|
|
<div class="field{% if err %} has-err{% endif %}{% if cls %} {{ cls }}{% endif %}">
|
|
<label for="f-{{ name }}">{{ label }}{% if req %} <span class="req" aria-hidden="true">*</span>{% endif %}</label>
|
|
<input id="f-{{ name }}" name="{{ name }}" type="{{ type }}" value="{{ value }}"{% if req %} required{% endif %}{% if list %} list="{{ list }}"{% endif %} autocomplete="{{ auto }}"{% if type == "date" %} min="1900-01-01" max="2100-12-31"{% endif %}{% if ph %} placeholder="{{ ph }}"{% endif %}{% if err %} aria-invalid="true" aria-describedby="e-{{ name }}"{% elif hint %} aria-describedby="h-{{ name }}"{% endif %}>
|
|
{%- if hint %}
|
|
<p class="hint" id="h-{{ name }}">{{ hint }}</p>
|
|
{%- endif %}
|
|
{%- if err %}
|
|
<p class="err" id="e-{{ name }}">{{ err }}</p>
|
|
{%- endif %}
|
|
</div>
|
|
{%- endmacro %}
|
|
|
|
{% macro select(name, label, value, options, err="", hint="", blank="Not recorded", cls="", req=false) -%}
|
|
<div class="field{% if err %} has-err{% endif %}{% if cls %} {{ cls }}{% endif %}">
|
|
<label for="f-{{ name }}">{{ label }}{% if req %} <span class="req" aria-hidden="true">*</span>{% endif %}</label>
|
|
<select id="f-{{ name }}" name="{{ name }}"{% if req %} required{% endif %}{% if err %} aria-invalid="true" aria-describedby="e-{{ name }}"{% endif %}>
|
|
<option value="">{{ blank }}</option>
|
|
{%- for o in options %}
|
|
<option value="{{ o[0] }}"{% if o[0] == value %} selected{% endif %}>{{ o[1] }}</option>
|
|
{%- endfor %}
|
|
</select>
|
|
{%- if hint %}
|
|
<p class="hint">{{ hint }}</p>
|
|
{%- endif %}
|
|
{%- if err %}
|
|
<p class="err" id="e-{{ name }}">{{ err }}</p>
|
|
{%- endif %}
|
|
</div>
|
|
{%- endmacro %}
|
|
|
|
{% macro area(name, label, value="", err="", hint="", rows=3, cls="", fcls="") -%}
|
|
<div class="field{% if err %} has-err{% endif %}{% if fcls %} {{ fcls }}{% endif %}">
|
|
<label for="f-{{ name }}">{{ label }}</label>
|
|
<textarea id="f-{{ name }}" name="{{ name }}" rows="{{ rows }}"{% if cls %} class="{{ cls }}"{% endif %} spellcheck="false"{% if err %} aria-invalid="true" aria-describedby="e-{{ name }}"{% endif %}>{{ value }}</textarea>
|
|
{%- if hint %}
|
|
<p class="hint">{{ hint }}</p>
|
|
{%- endif %}
|
|
{%- if err %}
|
|
<p class="err" id="e-{{ name }}">{{ err }}</p>
|
|
{%- endif %}
|
|
</div>
|
|
{%- endmacro %}
|