fix: no default date selected on expense form
All checks were successful
Deploy / build-and-deploy (push) Successful in 1m2s
All checks were successful
Deploy / build-and-deploy (push) Successful in 1m2s
This commit is contained in:
parent
e7fdea5375
commit
fb1a038821
1 changed files with 16 additions and 0 deletions
|
|
@ -125,6 +125,22 @@ templ AddExpenseForm(props AddExpenseFormProps) {
|
||||||
Attributes: templ.Attributes{"required": "true"},
|
Attributes: templ.Attributes{"required": "true"},
|
||||||
})
|
})
|
||||||
</div>
|
</div>
|
||||||
|
<script nonce={ templ.GetNonce(ctx) }>
|
||||||
|
(function() {
|
||||||
|
function todayISO() {
|
||||||
|
var d = new Date();
|
||||||
|
return d.getFullYear() + '-' + String(d.getMonth()+1).padStart(2,'0') + '-' + String(d.getDate()).padStart(2,'0');
|
||||||
|
}
|
||||||
|
var input = document.getElementById('date-hidden');
|
||||||
|
if (input && !input.value) input.value = todayISO();
|
||||||
|
var form = input && input.closest('form');
|
||||||
|
if (form) {
|
||||||
|
form.addEventListener('reset', function() {
|
||||||
|
setTimeout(function() { input.value = todayISO(); }, 0);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
// Tags
|
// Tags
|
||||||
<div>
|
<div>
|
||||||
@label.Label(label.Props{For: "new-expense-tags"}) {
|
@label.Label(label.Props{For: "new-expense-tags"}) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue