Initial commit of form submission struct.

This commit is contained in:
mikestefanello 2021-12-22 23:40:08 -05:00
parent b61077dac9
commit 57159c4fba
5 changed files with 126 additions and 21 deletions

View file

@ -1,3 +1,9 @@
{{define "csrf"}}
<input type="hidden" name="csrf" value="{{.CSRF}}"/>
{{end}}
{{define "form-field-errors"}}
{{range .}}
<p class="help is-danger">{{.}}</p>
{{end}}
{{end}}

View file

@ -1,11 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<html lang="en" style="height:100%;">
<head>
{{template "metatags" .}}
{{template "css" .}}
{{template "js" .}}
</head>
<body>
<body class="has-background-light" style="min-height:100%;">
<nav class="navbar is-dark">
<div class="container" hx-boost="true">
<div class="navbar-brand">
@ -28,12 +28,14 @@
<section class="section">
<div class="container">
{{- if .Title}}
<h1 class="title">{{.Title}}</h1>
{{- end}}
<div class="box">
{{- if .Title}}
<h1 class="title">{{.Title}}</h1>
{{- end}}
{{template "messages" .}}
{{template "content" .}}
{{template "messages" .}}
{{template "content" .}}
</div>
</div>
</section>
</body>

View file

@ -1,10 +1,11 @@
{{define "content"}}
<form id="contact" method="post" hx-post>
<form id="contact" method="post" >
<div class="field">
<label for="email" class="label">Email address</label>
<div class="control">
<input id="email" name="email" type="email" class="input" value="{{.Data.Email}}">
</div>
{{template "form-field-errors" (.Data.Submission.GetFieldErrors "email")}}
</div>
<div class="field">
@ -12,6 +13,7 @@
<div class="control">
<textarea id="message" name="message" class="textarea">{{.Data.Message}}</textarea>
</div>
{{template "form-field-errors" (.Data.Submission.GetFieldErrors "message")}}
</div>
<div class="field is-grouped">