HabitTracker/templates/habit.html

60 lines
2.3 KiB
HTML
Raw Normal View History

{% extends 'layouts/main.html' %}
{% block content %}
2024-01-23 11:17:24 +01:00
<h1 class="mt-5">Habit erstellen📋</h1>
2024-01-23 11:17:24 +01:00
<form action="/habit" method="POST">
<div class="mb-3">
<label for="name" class="form-label">Name der Gewohnheit</label>
2024-01-26 10:25:01 +01:00
<input type="text" class="form-control {% if errors.get('name') %} is-invalid {% endif %}" id="name" name="name" value="{{name}}">
2024-01-23 11:17:24 +01:00
<div class="invalid-feedback">
{{ errors.get('name', '') }}
</div>
</div>
<div class="mb-3">
<label for="note" class="form-label">Beschreibung</label>
2024-01-26 10:25:01 +01:00
<input type="text" class="form-control {% if errors.get('note') %} is-invalid {% endif %}" id="note" name="note" value="{{note}}">
2024-01-23 11:17:24 +01:00
<div class="invalid-feedback">
{{ errors.get('note', '') }}
</div>
</div>
<div class="row">
<div class="mb-3 col-2">
<label for="times" class="form-label">Häufigkeit</label>
2024-01-26 10:25:01 +01:00
<input type="number" min="1" class="form-control {% if errors.get('times') %} is-invalid {% endif %}" id="times" name="times" value="{{times}}">
2024-01-23 11:17:24 +01:00
<div class="invalid-feedback">
{{ errors.get('times', '') }}
</div>
</div>
<div class="mb-3 col-10">
2024-01-23 11:17:24 +01:00
<label for="unit" class="form-label">Im Zeitraum</label>
<select class="form-select {% if errors.get('unit') %} is-invalid {% endif %}" id="unit" name="unit">
<option value="Tag">Tag</option>
2024-01-26 10:25:01 +01:00
<option value="Woche">Woche</option>
<option value="Monat">Monat</option>
<option value="Jahr">Jahr</option>
</select>
2024-01-26 10:25:01 +01:00
<script>
document.addEventListener('DOMContentLoaded', (event) => {
let selectedElement = document.getElementById('unit');
for (let option of selectedElement.options) {
if (option.value == '{{ unit }}') {
option.selected = true;
break;
}
}
});
</script>
2024-01-23 11:17:24 +01:00
<div class="invalid-feedback">
{{ errors.get('unit', '') }}
</div>
</div>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
{% endblock %}