add form validation
This commit is contained in:
parent
82f11b254b
commit
3f2cbcea33
8 changed files with 131 additions and 18 deletions
|
@ -20,8 +20,10 @@
|
|||
<div class="text-right">
|
||||
<form action="/threads/{{.Thread.ID}}/{{.Post.ID}}" method="POST">
|
||||
{{.CSRF}}
|
||||
<textarea name="content" class="form-control border-0 border-bottom-1 p-3"
|
||||
placeholder="What are your thoughts?" rows="4"></textarea>
|
||||
<textarea name="content" class="form-control border-0 border-bottom-1 p-3 {{with .Form.Errors.Content}}is-invalid{{end}}"
|
||||
placeholder="What are your thoughts?" rows="4">
|
||||
{{- with .Form.Content}}{{.}}{{end -}}
|
||||
</textarea>
|
||||
<div class="border-top p-1">
|
||||
<button class="btn btn-primary btn-sm">Comment</button>
|
||||
</div>
|
||||
|
|
|
@ -9,12 +9,19 @@
|
|||
{{.CSRF}}
|
||||
<div class="form-group">
|
||||
<label>Title</label>
|
||||
<input name="title" type="text" class="form-control" placeholder="Give your post a great title">
|
||||
<input name="title" type="text" class="form-control {{with .Form.Errors.Title}}is-invalid{{end}}" placeholder="Give your post a great title" value="{{with .Form.Title}}{{.}}{{end}}">
|
||||
{{with .Form.Errors.Title}}
|
||||
<div class="invalid-feedack">{{.}}</div>
|
||||
{{end}}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Text</label>
|
||||
<textarea name="content" class="form-control" rows="3"
|
||||
placeholder="Tell people about your thoughts"></textarea>
|
||||
<textarea name="content" class="form-control {{with .Form.Errors.Content}}is-invalid{{end}}" rows="3" placeholder="Tell people about your thoughts">
|
||||
{{- with .Form.Content}}{{.}}{{end -}}
|
||||
</textarea>
|
||||
{{with .Form.Errors.Content}}
|
||||
<div class="invalid-feedack">{{.}}</div>
|
||||
{{end}}
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Submit Post</button>
|
||||
</form>
|
||||
|
|
|
@ -7,12 +7,20 @@
|
|||
{{.CSRF}}
|
||||
<div class="form-group">
|
||||
<label>Title</label>
|
||||
<input name="title" type="text" class="form-control" placeholder="Give your thread a great title">
|
||||
<input name="title" type="text" class="form-control {{with .Form.Errors.Title}}is-invalid{{end}}" placeholder="Give your thread a great title" value="{{with .Form.Title}}{{.}}{{end}}">
|
||||
{{with .Form.Errors.Title}}
|
||||
<div class="invalid-feedack">{{.}}</div>
|
||||
{{end}}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Description</label>
|
||||
<textarea name="description" class="form-control" rows="3"
|
||||
placeholder="Tell people what your thread is about"></textarea>
|
||||
<textarea name="description" class="form-control {{with .Form.Errors.Description}}is-invalid{{end}}" rows="3"
|
||||
placeholder="Tell people what your thread is about">
|
||||
{{- with .Form.Description}}{{.}}{{end -}}
|
||||
</textarea>
|
||||
{{with .Form.Errors.Description}}
|
||||
<div class="invalid-feedack">{{.}}</div>
|
||||
{{end}}
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Create Thread</button>
|
||||
</form>
|
||||
|
|
Reference in a new issue