30 lines
1.2 KiB
Django/Jinja
30 lines
1.2 KiB
Django/Jinja
<form method="post">
|
|
{% let validation_errors = validation_errors.clone().unwrap_or_default() %}
|
|
{% let field_errors = validation_errors.field_errors() %}
|
|
{% for input in inputs %}
|
|
<p>
|
|
<label for="{{ input.id }}">{{ input.label }}</label>
|
|
{% let name = std::borrow::Cow::from(*input.id) %}
|
|
{% if let Some(errors) = field_errors.get(name) %}
|
|
{% for error in errors %}
|
|
<small class="error">
|
|
{% if let Some(message) = error.message %}
|
|
{{ message }}
|
|
{% else %}
|
|
Mysterious validation error <code>{{ error.code }}</code>!
|
|
{% endif %}
|
|
</small>
|
|
{% endfor %}
|
|
{% endif %}
|
|
<input
|
|
type="{{ input.input_type }}"
|
|
id="{{ input.id }}"
|
|
autocomplete="{{ input.autocomplete }}"
|
|
{% if input.type_name.is_some() %}name="{{ input.id }}"{% endif %}
|
|
{% if input.required %}required{% endif %}
|
|
>
|
|
</p>
|
|
{% endfor %}
|
|
|
|
<button type="submit">{{ submit_label }}</button>
|
|
</form>
|