- Remove redundant spaces - Cleaner html in "view source" - Better html comments
55 lines
2.4 KiB
HTML
55 lines
2.4 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>{% if item %}Update{% else %}Add{% endif %} Item</title>
|
|
</head>
|
|
<body>
|
|
{% include 'header.html' %}
|
|
<h2>{% if item %}Update{% else %}Add{% endif %} Item</h2>
|
|
|
|
<!-- Display error message if any -->
|
|
{% if error %}
|
|
<p>{{ error }}</p>
|
|
{% endif %}
|
|
|
|
<!-- Form for adding/updating an item -->
|
|
<form method="POST">
|
|
{% for attrib in item_attributes -%}
|
|
<p>
|
|
<label for="{{ attrib.attrib_name }}">{{ attrib.display_name }}:</label>
|
|
{%- if attrib.html_input_type == "select" %}
|
|
<!-- Dropdown for select fields -->
|
|
<select id="{{ attrib.attrib_name }}" name="{{ attrib.attrib_name }}"
|
|
{%- if attrib.required -%} required {%- endif -%}
|
|
>
|
|
{% for option in attrib.options -%}
|
|
<option value="{{ option }}"
|
|
{%- if attrib.default_val is not none and attrib.default_val == option %} selected {%- endif -%}>{{ option -}}
|
|
</option>
|
|
{% endfor %}
|
|
</select>
|
|
{%- else %}
|
|
<!-- Input field for other inputs -->
|
|
<input id="{{ attrib.attrib_name }}" name="{{ attrib.attrib_name }}" type="{{ attrib.html_input_type }}"
|
|
{%- if attrib.required %} required {%- endif %}
|
|
{%- if attrib.min_val %} min="{{ attrib.min_val }}" {%- endif %}
|
|
{%- if attrib.max_val %} max="{{ attrib.max_val }}" {%- endif %}
|
|
{%- if attrib.step %} step="{{ attrib.step }}" {%- endif %}
|
|
{%- if attrib.max_length %} maxlength="{{ attrib.max_length }}" {%- endif %}
|
|
{%- if attrib.min_length %} minlength="{{ attrib.min_length }}" {%- endif %}
|
|
{%- if attrib.regex %} pattern="{{ attrib.regex }}" {%- endif %}
|
|
{%- if item %}
|
|
value="{{ item[attrib.attrib_name] }}"
|
|
{%- else %}
|
|
{%- if attrib.default_val is not none %} value="{{ attrib.default_val }}" {%- endif %}
|
|
{%- endif -%}
|
|
/>
|
|
{%- endif %}
|
|
</p>
|
|
{% endfor %}
|
|
<p><input type="submit" value="{% if item %}Update{% else %}Submit{% endif %}" /></p>
|
|
<button type="button" onclick="window.location.href='/'">Cancel</button>
|
|
</form>
|
|
</body>
|
|
</html> |